When you create a new UIView XIB in Interface Builder, it is by default full-screen. Width and height cannot be changed, they are dimmed out. What to do?
Switch to Simulated Metrics and change "Status Bar" from default (gray) to None. Now you can edit the size!
First time this was difficult to discover, second time I kind of recalled what to do and now it's all so plain obvious :)
Showing posts with label XIB. Show all posts
Showing posts with label XIB. Show all posts
Wednesday, April 20, 2011
How to Change UIView Size in Interface Builder
Monday, February 7, 2011
UITableView with Custom Cell Height
I'm writing an application, where startup view contains UITableView - which seemed pretty slow. Basic version is not too bad, but when using a custom UITableViewCell created from XIB, it became totally unusable.
Time to debug whether Interface Builder's XIB makes things slow!
Time to debug whether Interface Builder's XIB makes things slow!
Labels:
com.apple.debugserver,
heightForRowAtIndexPath,
NSLog,
rowHeight,
UITableView,
UITableViewCell,
UITableViewDelegate,
XIB
Thursday, November 11, 2010
How to Define UITableViewCell reuseIdentifier for loadNibNamed
When you create UITableViewCells, it's important to use reuseIdentified. This lets iOS recycle your table cells, thus improving performance and minimizing memory use. Using it is pretty simple:
Warning: you should NEVER access objects inside XIB (NIB) by magical index into array! Apple might change "something" in next Xcode release and thus break your code. You should use IBOutlets. You have been warned.
...yes, this is one of those sad "don't do as I do, but as I tell you to" cases...
static NSString *idCell = @"MyCellId";Try to reuse an already existing, but not currently used, cell created earlier with given identifier "MyCellId". If such isn't found, create a new one:
cell = (UITableViewCell *)[aTableView dequeueReusableCellWithIdentifier:idCell];
if (cell == nil)This code requires a separate stand-alone XIB, which contains nothing but your UITableViewCell. But how do you define the reuseIdenfier? That property is read-only and created when table cell is created.
{
static NSString *nibcell = @"MyCell";
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:nibCell owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
}
reuseIdentifierOpen your XIB in Interface Builder, select UITableViewCell object, open "Table View Cell Attributes" (press command-1) and write your hardcoded magical string "MyCellId" into "Identifier" field. Use the same string in your code as reuseIdentifier.
A string used to identify a cell that is reusable. (read-only)
@property(nonatomic, readonly, copy) NSString *reuseIdentifier
Warning: you should NEVER access objects inside XIB (NIB) by magical index into array! Apple might change "something" in next Xcode release and thus break your code. You should use IBOutlets. You have been warned.
...yes, this is one of those sad "don't do as I do, but as I tell you to" cases...
Labels:
dequeueReusableCellWithIdentifier,
IBOutlet,
interface builder,
iphone,
loadNibNamed,
mainBundle,
NSBundle,
NSString,
objectAtIndex,
reuseIdentifier,
UITableViewCell,
XIB
Monday, March 15, 2010
Interface Builder cannot change UIView color
If you fail to change UIView color in Interface Builder, it could be because Emulator is blocking your changes. Close emulator and try again.
Monday, March 1, 2010
How to Create a Black Statusbar
When you open MainWindow.xib in Interface Builder, you can find "Window - Status Bar" and "MainViewController - Status Bar". Setting either one or both as "Black" doesn't seem to have any effect on the actual application. Your statusbar remains gray.
So how do I get a black statusbar?
Open your application .plist file, click on plus icon (+) to create a new row and write "Status bar style" as name and select "Opaque black style" as value.
Those are "key = UIStatusBarStyle" and "string = UIStatusBarStyleOpaqueBlack if you're more familiar with that style.
So how do I get a black statusbar?
Open your application .plist file, click on plus icon (+) to create a new row and write "Status bar style" as name and select "Opaque black style" as value.
Those are "key = UIStatusBarStyle" and "string = UIStatusBarStyleOpaqueBlack if you're more familiar with that style.
Labels:
interface builder,
iphone,
plist,
UIStatusBarStyle,
XIB
Tuesday, February 16, 2010
Why viewWillAppear Wasn't Called?
Have several views defined as XIB, work just fine as standalone views and as main views under UITabBar. However they stopped working when added them as subviews under main view in UITabBar (don't ask...)
The problem was that viewWillAppear wasn't called automatically, because I added the views manually under another view. Apple documentation suggests calling the missing function manually - and yet again everything works just fine!
The problem was that viewWillAppear wasn't called automatically, because I added the views manually under another view. Apple documentation suggests calling the missing function manually - and yet again everything works just fine!
self.myController =
[[MyViewController alloc]
initWithNibName:@"MyViewController" bundle:nil];
[self.mainView addSubview:myController.view];
[self.myController viewWillAppear:YES];
Labels:
interface builder,
iphone,
UITabBar,
viewWillAppear,
XIB
Subscribe to:
Posts (Atom)


