Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Error on iOS7 #23

Closed
paulocoutinhox opened this issue May 12, 2015 · 11 comments
Closed

Error on iOS7 #23

paulocoutinhox opened this issue May 12, 2015 · 11 comments

Comments

@paulocoutinhox
Copy link

Hi,

I have a problem on iOS7 only with my customers. Im receiving the error that is a bug on iOS7 and it is a common error but i tried without success solve it.

Can you help me?

@ermalkaleci
Copy link
Owner

ermalkaleci commented May 12, 2015 via email

@paulocoutinhox
Copy link
Author

It crash the app when running on iOS7.
I'm dont using autolayout or interface builder and when i use ths library on iOS7 it crash with the errors that i show on link, is the same problem.
But on iOS8 it is working.

@paulocoutinhox
Copy link
Author

I did made i simple sample of the problem:

https://github.com/prsolucoes/CarbonKitError

@paulocoutinhox
Copy link
Author

The error happens on line:

- (void)didMoveToSuperview {  
         ....  
    [self setTranslatesAutoresizingMaskIntoConstraints:NO];  
         ....  
 }  

If you comment, it dont crash, but the view is not centralized.

@ermalkaleci
Copy link
Owner

Library require auto-layout, anyway I will check what I can do.

@paulocoutinhox
Copy link
Author

I had added a README file on my sample repository to you see. Please, help me with this :(

@ermalkaleci
Copy link
Owner

You can not add CarbonSwipeRefresh as subview of tableView.
You need to add it on tableView container, like in the example

@ermalkaleci
Copy link
Owner

#import "ViewController.h"

@interface ViewController ()
{
    UITableView *tableView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"CarbonKit - Error - iOS7";

    tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    [self.view addSubview:tableView];

    [self enablePullToRefresh];
}

- (void)enablePullToRefresh
{
    self.refresh = [[CarbonSwipeRefresh alloc] initWithScrollView:tableView];
    [self.refresh setMarginTop:64];
    [self.view addSubview:self.refresh];
    [self.refresh addTarget:self action:@selector(pullToRefresh:) forControlEvents:UIControlEventValueChanged];
}

- (void)pullToRefresh:(id)sender
{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.refresh endRefreshing];
    });
}

@end

@ermalkaleci
Copy link
Owner

CarbonSwipeRefresh can't be child of tableView. It must be child of tableview parent. You need to add a tableView inside a viewController not directly in UITableViewController
this is the header or your example:

#import <UIKit/UIKit.h>
#import <CarbonKit/CarbonKit.h>

@interface ViewController : UIViewController

@property (nonatomic, retain) CarbonSwipeRefresh *refresh;

- (void)enablePullToRefresh;
- (void)pullToRefresh:(id)sender;

@end

replace UITableViewController with UIViewController

@paulocoutinhox
Copy link
Author

Ok, i have made the correction on project. It is working now, but i need put the code

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
}

I need it?

@ermalkaleci
Copy link
Owner

I closed this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants