Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-11-2008, 06:02 PM   #1 (permalink)
cgraus
New Member
 
Join Date: Oct 2008
Posts: 39
Default Adding a UISegmentedControl

My app works great on the emulator, but not so good on the phone. Two issues:

1 - I have a UIScrollView that contains a UIImageView, on the phone, sometimes the UIImageView never paints itself, so that area shows the results of a table view that animated out to reveal it. This never happens in the emulator

2 - the application is prone to crashing, and my logging makes me think it's within this code:


// called after this controller's view will appear
- (void)viewWillAppearBOOL)animated
{
NSLog(@" DCOImageDisplayController - (void)viewWillAppearBOOL)animated called" );
// for aesthetic reasons (the background is black), make the nav bar black for this particular page
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

// match the status bar with the nav bar
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
visible = YES;
currentIndex = 0;

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[UIImage imageNamed:@"left arrow.png"],
[UIImage imageNamed:@"right arrow.png"],
nil]];
[segmentedControl addTarget:self action:@selector(segmentAction forControlEvents:UIControlEventValueChanged];
segmentedControl.frame = CGRectMake(0, 0, 90, 40);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.momentary = YES;
[segmentedControl setTintColor:[UIColor blackColor]];

UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];

self.navigationItem.rightBarButtonItem = segmentBarItem;

}

I've tried adding the SegmentedControl in other places, so it doesn't get created every time, but I've been unable to make this work. Does anyone have any suggestions ?

Actually, while I'm not sure this is not an issue, as I've made this view a member variable, I am wondering if it being a member is why my images never update, once the first has been set ( although this doesn't make a whole lot of sense, none of this makes sense to me ). However, when the app crashes, this method actually finishes ( I added some logging to say the method was done ) and then the app freezes. It works fine on the emulator, so I am not sure what is going wrong.

Last edited by cgraus; 10-11-2008 at 06:14 PM. Reason: Adding some detail
cgraus is offline   Reply With Quote
 

» Advertisements
» Online Users: 697
22 members and 675 guests
306Designs, apatsufas, BrianSlick, chits12345, ckgni, coder, Dani77, devangvyas, Domele, ghost, JamesCahall, jameswilliards, k2c, my02820, nitingohel, Objective Zero, Oral B, Prajakta, rky, robin4kneb, skrew88, Vad
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,783
Threads: 89,204
Posts: 380,594
Top Poster: BrianSlick (7,129)
Welcome to our newest member, robin4kneb
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:58 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.