cocoa-touch

slow scrolling of UITableView [duplicate]

☆樱花仙子☆ 提交于 2020-01-20 07:08:47
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: UIImage in uitableViewcell slowdowns scrolling table I filled my table view data with plist file which will download from a server . but after user scrolls the table the scrolling is very slow ! this is my code : //this is my plist code that load from server NSURL *url = [NSURL URLWithString:@"http://example.com/news.plist"]; titles = [[NSArray arrayWithContentsOfURL:url] retain]; tableview : - (NSInteger

Does Interface Builder use the -init method to initialize view controllers?

左心房为你撑大大i 提交于 2020-01-19 20:29:39
问题 I have setup tab bar controller using interface builder, and each tab bar item is linked to a view controller (4 tabs, 4 view controllers). I want to know if Interface Builder uses an -init method to initialize the view controller because apparently this method does not get called: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil; ... and I want to do some initializations. I can't add that to -viewDidLoad since it is recalled in case of memory warning. Any idea

Does Interface Builder use the -init method to initialize view controllers?

 ̄綄美尐妖づ 提交于 2020-01-19 20:28:07
问题 I have setup tab bar controller using interface builder, and each tab bar item is linked to a view controller (4 tabs, 4 view controllers). I want to know if Interface Builder uses an -init method to initialize the view controller because apparently this method does not get called: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil; ... and I want to do some initializations. I can't add that to -viewDidLoad since it is recalled in case of memory warning. Any idea

UITableView - Directly setting tableHeaderView property vs. Implementing -viewForHeaderInSection method

余生颓废 提交于 2020-01-19 12:49:25
问题 What's the difference between directly setting the tableHeaderView/tableFooterView properties: UIView *headerView = [[UIView alloc] init...]; tableView.tableHeaderView = headerView; [headerView release]; and implementing the viewForHeaderInSection/viewForFooterInSection methods?: - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[[HeaderView alloc] init...] autorelease]; return headerView; } 回答1: the first is the header of a table

UITableView - Directly setting tableHeaderView property vs. Implementing -viewForHeaderInSection method

陌路散爱 提交于 2020-01-19 12:48:30
问题 What's the difference between directly setting the tableHeaderView/tableFooterView properties: UIView *headerView = [[UIView alloc] init...]; tableView.tableHeaderView = headerView; [headerView release]; and implementing the viewForHeaderInSection/viewForFooterInSection methods?: - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[[HeaderView alloc] init...] autorelease]; return headerView; } 回答1: the first is the header of a table

How do you remove extra empty space in NSString?

和自甴很熟 提交于 2020-01-19 10:08:59
问题 is there a simple way to remove the extra spaces in a string? ie like... NSString *str = @"this string has extra empty spaces"; result should be: NSString *str = @"this string has extra empty spaces"; Thanks! 回答1: replace all double space with a single space until there are no more double spaces in your string. - (NSString *)stripDoubleSpaceFrom:(NSString *)str { while ([str rangeOfString:@" "].location != NSNotFound) { str = [str stringByReplacingOccurrencesOfString:@" " withString:@" "]; }

How do you remove extra empty space in NSString?

梦想与她 提交于 2020-01-19 10:07:50
问题 is there a simple way to remove the extra spaces in a string? ie like... NSString *str = @"this string has extra empty spaces"; result should be: NSString *str = @"this string has extra empty spaces"; Thanks! 回答1: replace all double space with a single space until there are no more double spaces in your string. - (NSString *)stripDoubleSpaceFrom:(NSString *)str { while ([str rangeOfString:@" "].location != NSNotFound) { str = [str stringByReplacingOccurrencesOfString:@" " withString:@" "]; }

CADisplayLink stops updating when UIScrollView scrolled

旧街凉风 提交于 2020-01-19 05:16:11
问题 Title is quite self explanatory, but I have some animation being done in a loop triggered by CADisplayLink. However, as soon as I scroll a UIScrollView I have added to my view hierarchy, the animation stops immediately, only to return again when scrolling has completely stopped and come to a standstill.... Anyway to cancel this behaviour? 回答1: Run the display link (using -addToRunLoop:forMode: ) on another thread with another run loop. So create a new thread, create a run loop on that thread,

Advantages, problems, examples of adding another UIWindow to an iOS app?

安稳与你 提交于 2020-01-18 05:46:33
问题 Recently I've been wondering about the fact that that an iOS app only has one UIWindow . It does not seem to be an issue to create another UIWindow and place it on screen. My question is kind of vague, but I'm interested in: What could I potentially achieve with a second UIWindow that cannot be done in other ways? What can go wrong when using multiple UIWindow instances? I have seen that people use a 2nd UIWindow to display popover like views on iPhone. Is this a good way of doing it? Why?

NSCalendar.components().minute returning inconsistent values

别来无恙 提交于 2020-01-17 14:46:21
问题 Original problem is encountered during my post, testing and code in the link below https://stackoverflow.com/questions/27339072/working-with-nsdate-components-in-swift/30822018#30822018 Here is the minimal test-case I am creating a date that is offset from a particular date (self in this case as I do it in NSDate() extension) using NSCalendar.dateByAddingUnit(..., value:x, ...) I then get a difference "fromDate" (created date or self) "toDate" (current time which is NSDate()) using NSCalendar