Hi I regulary created using IB one UISegmentedControl that I called showAllSwitch.
If I try to do [showAllSwitch setHidden:YES]; nothing happens!
Why? How can I do to hide it?
Where are you calling setHidden? if it is being called before it is added to the view, then there could be problems. Try calling it in viewDidAppear and see it that works. If it doesn't either the segmentedControl is not connected correctly in IB, or there is a rather big problem that we are missing.
Hiding an object is relatively straight forward. So if there is a problem then its something simple. You need to just go through some basic diagnostic steps:
Verify that your segmented control is actually connected to the correct outlet in IB. Really. Go look. Even if you are sure. Go look again.
Verify that the line where you are hiding it is being called. Add an NSLog just after and see if it shows up when it should.
Make sure that the hide command is not getting sent too soon. If its being sent in ViewDidLoad try setting it up in ViewDidAppear.
Related
I have two buttons in my view. When I sent the tag value of one of them in Interface Builder they stop working. I get EXC_BAD_ACCESS error.
Have you linked the button in IB to an actual field? If not, then when you access the field it won't actually refer to the button.
Set the button tag in code programmatically. then in the method which calls the button if(button.tag== [sender tag]){}
Before posting please make sure that you describe your problem clearly.
Make sure all the wiring's are perfect,and look at your your console.
There will be some hints about what is exactly going wrong.
I just added a UIDatePicker to my iPad app using IB, linked it to its outlet in the code, saved it in IB, added the UIPickerViewDelegate to my UIViewController in the code, as well as added the UIDatePicker outlet in code. When I build and run, the app launches, but will crash intermittently when I attempt to open the popover view that contains the datepicker. I say intermittently because the popover view will occasionally open successfully, but never more than once (it always crashes the second time you open the popover, if it doesn't crash the first time). Also, in the console, I get the following messsage
objc[594]: FREED(id): message lastClickRow sent to freed object=0x6015a70
Why is this happening and how can I fix it?
What does that console message indicate?
It may be worth mentioning that the popover view also contains a table view along with the datepicker control.
Thanks so much in advance for your help!
I too had a tough time getting through this problem but at last got it resolved.
Instead of adding UIDatePicker in interface builder, add it dynamically or programatically. It surely worked for me and hope that it works for you too.
UIDatePicker *_datePicker=[[UIDatePicker alloc] initWithFrame:frame];
[self.view addSubview:_datePicker];
This is almost certainly a reference count issue. It seems odd that your view controller (which I'm assuming is the delegate of your UIDatePicker, since that's where you implemented the protocol) would be released during normal operations, but that's the first thing you should look at - that the delegate is set and remains a valid object at the time you display the popup view.
One funny thing you could have done is to release it UIPopOverController reference after passing it the [presentPopover...] message, just like we do at passing a presentModalViewController message to the UIViewController.
I faced this problem too, one thing you can do is something like
self.funnyPopoverController = aPopoverController;
(of course funnyPopoverController is retain type property here).
Otherwise its hard to predict whats happening without staring at the code for some long long time_t hours :)
I've got a custom UIViewController that loads a xib. The first time it's instantiated, it takes some time before it appears. Is there an elegant way to preload it, so it won't do this? I tried just creating it and immediately after release it. That didn't seem to work. I suppose if I wanna do it that way, I'd have to add it to the main window (for example), and then remove it. But in any case, that solution seems a bit ugly. Any other way?
Try creating it and calling [controller view]. This will load its xib and create and hook up its view outlet, etc.
I need some help. This seems to be a common problem I am having when am adding and changing views in my coding. And I would love to learn what I am doing wrong.
Currently I am adding and removing views using the following calls from my view controller:
[startView removeFromSuperview];
[self addSubview:secondView];
and then doing the opposite again to go back.
[secondView removeFromSuperview];
[self addSubview:startView];
I am fine up to this point.
But the problem I have is that when I then decide to go back to 'startView" and call the first code that I have above for the second time.
My View loads but very little works.
None of my methods are called, there is no animation and the view is shown but it is "dead" or "asleep". And I have no idea why!
I am basically adding a view, removing it, then adding it again and everything breaks.
Can anyone give me a hand as to what might be happening? is it that ViewDidLoad doesn't fire the second time it's loaded? or something like that?
I would much appreciate it.
I may have figured it out So don't worry!
I had a flag hidden in my code somewhere that was stopping my methods from firing.
Sorry!
I can't find any documentation to confirm this, but it appears that you can only call the method stringByEvaluatingJavaScriptFromString in overridden methods from a UIWebView delegate. Can anyone confirm this?
Here's what I've tried. I setup a button on a view, link it to a method on my viewcontroller, and make sure it works fine. My view has a UIWebView control on it as well. If I run the project on the simulator or on the iPhone, there are no issues. Then I add this code to the button's method.
[theWebView stringByEvaluatingJavaScriptFromString:#"alert('Hi there!');"];
When I run the project, I can click the button and see the 'Hi there' prompt and I can click OK to dismiss it. Usually 4-5 seconds later the simulator crashes. I occasionally see the "__TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION__" error, but not consistently; sometimes there's no error. It also doesn't always crash the first time. Sometimes I go to another page, and then try it again, and it crashes.
If I put the same code in the webPageDidFinishLoad event it works fine. But I'd like the code to be called when the user demands it so that event doesn't suit my needs.
I'm open to a workaround if you have any ideas? Thanks in advance!
I still don't know the exact reason this didn't work, but I found I could rewrite my code to get called during the UIWebView delegate methods instead.