Skip to main content

Posts

Showing posts with the label uiview

What is the relationship between UIView"s setNeedsLayout, layoutIfNeeded and layoutSubviews?

Can anyone give a definitive explanation on the relationship between UIView's setNeedsLayout, layoutIfNeeded and layoutSubviews methods? And an example implementation where all three would be used. Thanks. What gets me confused is that if I send my custom view a setNeedsLayout message the very next thing it invokes after this method is layoutSubviews, skipping right over layoutIfNeeded. From the docs I would expect the flow to be setNeedsLayout > causes layoutIfNeeded to be called > causes layoutSubviews to be called.

What happens to my subView when changing navigation controllers?

Lets say that I add a subView to my view, like this: [[self addSubview:myView]; Then I push a new view onto the navigationController stack, like this: [self.navigationController pushViewController:otherView animated:YES]; What happens to the subView that I added to the original view. Is it removed automatically? Also, if my program calls this line: [[self addSubview:myView]; multiple times without removing the view does that do anything bad like create a memory leak?

insertSubview:belowSubview: in UITableViews

I have a UITableView with UITableViewCell s that are swipable. When a cell is swiped, I want a view to be visible (revealed) underneath that cell. Here's the code that I have: UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; _cellBack = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; _cellBack.backgroundColor = [UIColor whiteColor]; [self.tableView insertSubview:_cellBack belowSubview:cell]; for (int i = 0; i < [self.tableView subviews].count; i++) { UIView *v = [[self.tableView subviews] objectAtIndex:i]; if ([v isEqual:_cellBack]) { NSLog(@"cellBack %d", i); } if ([v isEqual:cell]) { NSLog(@"cell %d", i); } } In the for loop, I check to see if the views' indexes are as I expect, and indeed they are; _cellBack has an index that is one less than cell 's index. When I replace the insertSubview:belowSubview: call wit

add uiview at row selection

I want when tab on row a uiview containing two button appear at the center of the cell, so I did the following code - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //how can I get the text of the cell here? UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIView *v = [[UIView alloc] init]; v.center = cell.center; UIButton*button1 =[[UIButton alloc] init]; button1.frame = CGRectMake(v.center.x - 5 , v.center.y , 5 , v.center.y + 4 ); button1.titleLabel.text = @"I'm label 1"; [v addSubview: button1]; UIButton*button2 =[[UIButton alloc] init]; button2.frame = CGRectMake(v.center.x - + 1 , v.center.y , 5 , v.center.y + 4 ); button2.titleLabel.text = @"I'm label 2"; [v addSubview: button2]; [cell addSubview:v]; /* <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"&

Program a "No Photos In Albums&rdquo; screen

Is there a way to access this screen and edit it for your own program? Id want to change the "No Photos" text label. I already know how to edit the "albums" label, because I already built my UINavigation Controller. I guess mainly I want to know if this screen is usable or accessible to developers. EDIT: I don't want to access albums or the photo application from my program. I just want that image of the stacking photos in my application.

Adding UIView subclass programmatically not drawing itself

I don't understand how this works. If I draw a UIView object to my UIViewController .xib file, then my UIView redraws itself. If I add it to the subView like CustomView : UIView in UIViewController's viewDidLoad CustomView *v = [[CustomView alloc] initWithFrame:self.view.frame]; [self.view addSubview:v]; The CustomView not draw itself. I then tried to do [self.view setNeedsDisplay]; and I still get nothing. Just a white background (different than the black background I was getting before), but none of my drawing. How does it work when you add a UIView programmatically? thanks.

iPhone autoresizingmasks

I've been experiencing problems with designing views so that the subviews behave the way I want when using autoresizingmasks (for example, if the status bar size changes, when using the phone as a hotspot etc.). Is there any good documentation that I should definitely read? Apple documents don't seem to help me at least not without some heavy testing of my own.