How to hide buttons in iOS when webview has finished loading - iphone

I am not sure why is this set of codes not working to hide iphone buttons as soon as the webview has loaded?
GoogleMap_BetaViewController.h
#interface GoogleMap_BetaViewController : UIViewController <UIWebViewDelegate> {
IBOutlet UIWebView *webView;
UIButton *retrieveReminder;
}
#property (nonatomic, retain) UIWebView *webView;
#property (nonatomic, retain) IBOutlet UIButton *retrieveReminder;
- (IBAction) RetrieveReminder:(id)sender;
#end
testController.m
#implementation GoogleMap_BetaViewController
#synthesize webView,retrieveReminder;
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
[retrieveReminder setHidden:YES];
}

Jonathan, have you connect UIWebViewDelegate properly ? Have you check that WebViwDidFinishLoad get called everytime.

As commented in response above, make sure that you are going from Files Owner to the Button and not the Button to Files Owner (which will show you IBActions). Also, once you get the right variable hooked up, make sure you are using self.retrieveReminder so that you are accessing the variable through the getters/setters which is what the IBOutlet is hooked up to.

Based on our discussion in the comments, I guess you are linking it wrongly. Take a look at this video for a visual tutorial on linking IBOutlets. http://www.youtube.com/watch?v=-EpTGOcC0Jw

You need to set the webFiview delegate to self and then use its delegate method:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
button.hidden = YES;
}
Have you tried to set the delegate of the webview in the IB? That is a must, as you are using its delegate method.

Related

No visible #interface for UIButton declares the selector"setbookmarkState

Declared BOOL
#property (nonatomic, assign) BOOL BookmarkState;
When using the BOOL for UIButton added on navigationbar using storyboard
[_bookmarkbtn setBookmarkState:NO];
then gets ARC Semantic issue
No visible #interface for UIButton declares the selector"setbookmarkState
EDIT:
PageViewController h file
#interface PageViewController : UIViewController <UIPageViewControllerDelegate, UIPageViewControllerDataSource>
#property (nonatomic, assign) BOOL BookmarkState;
#end
PageViewController m file
#interface PageViewController () {
BOOL BookmarkState;
}
#property (strong, nonatomic) IBOutlet UIButton *bookmarkbtn;
#implementation PageViewController
UIButton has no property called bookmarkState.
If you want to disable your button bookmarkbtn, use [_bookmarkbtn setEnabled:NO];
Or if you want to deselect it, use [_bookmarkbtn setSelected:NO];
Or if you want to unhighlight it, use [_bookmarkbtn setHighlighted:NO];
If you want to set the bookmarkState to NO, use [self setBookmarkState:NO];
Edit: it seems like you've named the booleans differently (one with lowercase, and one with uppercase) so my question is - are you certain of what are you doing / of what are you trying to accomplish?
Pardon me if it will sound rude or disrespectful, but calling setbookmarkState on UIButton is clearly showing that you aren't quite sure of how to do something you that you need.
Also, XCode should give you an error stating that no visible interface for UIButton declares the selector setbookmbarState:
First of all - as stated, UIButton has no property bookmarkState.
Then, calling an autosynthesized setter method always implies that you use setMyProperty, not setmyProperty, or setmyproperty. It's weird how you got it to run :)
Good luck!

iOS 6 issue during setting text on a label

I've a problem with some label. I made a public method that takes information from a table view and shows this info in 3 label, a text view and it load a pic from the web. I setup all the variable in the table view didSelectRowAtIndexPath method, but I'm having some issue to display that info. I made so:
in the table view controller I called the other method so:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.detailCharacterViewController = [[DetailCharacterViewController alloc] init];
[self.detailCharacterViewController setupDetailViewControllerWithName:[self.arrayCharacters[indexPath.row] objectForKey:#"name"] andSurname:[self.arrayCharacters[indexPath.row] objectForKey:#"surname"] andKind:[self.arrayCharacters[indexPath.row] objectForKey:#"kind"] andDescription:[self.arrayCharacters[indexPath.row] objectForKey:#"description"] andImage:[self.arrayCharacters[indexPath.row] objectForKey:#"URLpic"]];
}
and I implemented the method so:
- (void)setupDetailViewControllerWithName:(NSString*)name andSurname:(NSString *)surname andKind:(NSString*) kind andDescription:(NSString*)description andImage:(NSString*)url {
NSLog(#"name = %#", name);
self.labelName.text = name;
self.labelSurname.text = surname;
self.labelKind.text = kind;
self.textDescription.text = description;
NSURL *urlPic = [NSURL URLWithString:url];
NSData *dataPic = [NSData dataWithContentsOfURL:urlPic];
[self.imagePic setImage:[UIImage imageWithData:dataPic]];
}
If I look to the log i see the right things, but if I look to the GUI on iPhone or iPhone simulator it will remain blank. What's wrong with this code?
Thank you for the suggestion.
#Alex Blundell
#import <UIKit/UIKit.h>
#interface DetailCharacterViewController : UIViewController
#property (weak, nonatomic) IBOutlet UILabel *labelName;
#property (weak, nonatomic) IBOutlet UILabel *labelSurname;
#property (weak, nonatomic) IBOutlet UILabel *labelKind;
#property (weak, nonatomic) IBOutlet UIImageView *imagePic;
#property (weak, nonatomic) IBOutlet UITextView *textDescription;
- (void)setupDetailViewControllerWithName:(NSString*)name andSurname:(NSString *)surname andKind:(NSString*) kind andDescription:(NSString*)description andImage:(NSString*)url;
#end
The problem is that your DetailCharacterViewController's view is not loaded yet when you call setupDetailViewControllerWithName:..., so none of the outlets are connected (yet). Instantiating a view controller via alloc-init does not load its view automatically.
You could force loading the view by calling [self view] at the beginning of your setup method. This works because accessing the view property will automatically load the view if it wasn't loaded before.
Alternatively, you could make the name, surname, etc. NSString properties of the view controller and set the corresponding labels in viewDidLoad.
Are you using Interface Builder/Storyboards to design your interface? Have you made sure to connect the IBOutlets for each UITextField/View?
You should identify the objects in the header file on your view controller class, and ensure they're prefixed by IBOutlet for them to appear in Interface Builders connections pane. E.g.
IBOutlet UITextField labelName;
[...]
Then you need to go to IB and go to the connections pane for the view controller to connect each text field/view.
This problem happened to me as well.
It has to do with the fact that iOS actually hooks up your outlets really really late.
If you put a breakpoint in your setupDetailViewControllerWithName: and check your IBOutlet variables, they will be nil. That's why you are seeing a blank view. (The good old nil erroring)
The work-around I will do is to declare properties in the DetailCharacterViewController class. (Such as #property (copy, nonatomic) NSString* name).
And in the place where you are calling setupDetailViewControllerWithName:, set those properties instead such as:
self.detailCharacterViewController.name = name;
Finally in your DetailCharacterViewController's viewDidLoad:, you set the values of the labels using the saved properties. (The outlets are for sure hooked up then).
(By the way, this problem exists for prepareForSegue: as well. The destination view controller's outlets are all still nil in prepareForSegue:. So you cannot set them directly there yet)

how to make a drop down list for iphone application

I want to make a drop down list for iphone application i want that when user click it show list and when click on any button it shows that value and hides list i have implemented using the follwoing code but this work only for one value not for others
#interface DropDownViewController : UIViewController {
IBOutlet UILabel*ddText;
IBOutlet UILabel*ddMenu;
IBOutlet UIButton*ddMenuShowButton;
}
#property (nonatomic, retain) IBOutlet UILabel *ddText;
#property (nonatomic, retain) IBOutlet UIView *ddMenu;
#property (nonatomic,retain) IBOutlet UIButton *ddMenuShowButton;
- (IBAction)ddMenuShow:(UIButton *)sender;
- (IBAction)ddMenuSelectionMade:(UIButton *)sender;
#end
#implementation DropDownViewController
#synthesize ddMenu, ddText;
#synthesize ddMenuShowButton;
- (IBAction)ddMenuShow:(UIButton *)sender
{
self.ddMenu.hidden = NO;
[sender setTitle:#"▲" forState:UIControlStateNormal];
}
- (IBAction)ddMenuSelectionMade:(UIButton *)sender
{
self.ddText.text = sender.titleLabel.text;
[self.ddMenuShowButton setTitle:#"▼" forState:UIControlStateNormal];
self.ddMenu.hidden = YES;
}
I have three button red grenn blue first is red it works only for red only not for others how to solve this i have used this following this tutorial
http://www.edumobile.org/iphone/iphone-programming-tutorials/a-simple-drop-down-list-for-iphone/
Add UIbutton near your textfield.While clicking that button create UITableview according to your textfileld size.(Hope you know about creating Uitableview)and then load your listview contents in "cellForRowIndex".While selecting the row of the table,you can get the value from "didselectrowatIndexPath" and load it in textfield.After that remove UItableview.
It would be good if you use iPhone tools in your application. You should use UIPickerView in the place of drop down list. It looks good and provides better interface in mobile application

How to add a popup UIView (of a customized class) on a UIViewController

I'm new on this, and I would like to get some advice because I don't know what I'm doing wrong.
I want to make an app in xcode, with a UIView with some items, and when you do something, another UIView (smaller than the first) pops up above the first UIView. The popup UIView would be a customized class.
I have started with the UIViewController template and the initial UIView, and I have linked all the items in the .storyboard, and it works. But when I create my own UIView class (from objective-C class), put the second UIView over the first in the storyboard and link it to my class, something goes wrong.
The UIView appears, but when I try to set it to hidden, it doesn't answer. It's like it's not receiving the messages, so I think I don't link it well programmatically and just appears because of the storyboard.
I don't know if I have to create another UIViewController instead of the UIView, or if this is the correct path.
Can anybody explain me a little, or just write a little code snippet with the instantiation of the second view and adding it?
Lots of thanks!!
(I paste some code, of the declaration in .h and instantiation in .m)
#import <UIKit/UIKit.h>
#import "EditView.h"
#interface ReleaseViewController : UIViewController <UIWebViewDelegate, UISearchBarDelegate> {
IBOutlet UIWebView *web;
IBOutlet UISearchBar *search;
IBOutlet EditView *evHack;
}
#property (nonatomic, retain) IBOutlet UIWebView *web;
#property (nonatomic, retain) IBOutlet UISearchBar *search;
#property (nonatomic, retain) IBOutlet EditView *evHack;
#end
- (void)viewDidLoad
{
[super viewDidLoad];
search.delegate = self;
web.delegate = self;
evHack = [evHack initWithFrame:CGRectMake(0, 44, 320, 377)];
[evHack setHidden:YES];
}
EditView Class (I still have nothing):
#import <UIKit/UIKit.h>
#interface EditView : UIView
#end
#import "EditView.h"
#implementation EditView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
NSLog(#"View created");
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
#end
initWithFrame only works when you alloc/init an app. If its already initialized, in this case by the storyboard, just set its frame:
evHack.frame = CGRectMake(0,44, 320, 377);
I don't know what it looks like in IB, But setting its frame in code may be redundant if you set it in IB too. To check whether evHack is hooked up right, NSLog evHack in viewDidLoad. If you get nil back, it's not hooked up right.

Sharing a UIView between UIViewControllers in a UITabBarController

I have a UIScrollView that houses a gallery of images the user can scroll through. This view needs to be visible on each of three separate UIViewControllers that are housed within a UITabBarController. Right now, I have three separate UIScrollView instances in the UITabBarController subclass, and the controller manages keeping the three synchronized (when a user scrolls the one they can see, programmatically scrolling the other two to match, etc.), which is not ideal.
I would like to know if there is a way to work with only ONE instance of the UIScrollView, but have it show up only in the UIViewController that the user is currently interacting with. This would completely eliminate all the synchronization code. Here is basically what I have now in the UITabBarController (which is where all this is currently managed):
#interface ScrollerTabBarController : UITabBarController {
FirstViewController *firstView;
SecondViewController *secondView;
ThirdViewController *thirdView;
UIScrollView *scrollerOne;
UIScrollView *scrollerTwo;
UIScrollView *scrollerThree;
}
#property (nonatomic,retain) IBOutlet FirstViewController *firstView;
#property (nonatomic,retain) IBOutlet SecondViewController *secondView;
#property (nonatomic,retain) IBOutlet ThirdViewController *thirdView;
#property (nonatomic,retain) IBOutlet UIScrollView *scrollerOne;
#property (nonatomic,retain) IBOutlet UIScrollView *scrollerTwo;
#property (nonatomic,retain) IBOutlet UIScrollView *scrollerThree;
#end
#implementation ScrollerTabBarController
- (void)layoutScroller:(UIScrollView *)scroller {}
- (void)scrollToMatch:(UIScrollView *)scroller {}
- (void)viewDidLoad {
[self layoutScroller:scrollerOne];
[self layoutScroller:scrollerTwo];
[self layoutScroller:scrollerThree];
[scrollerOne setDelegate:self];
[scrollerTwo setDelegate:self];
[scrollerThree setDelegate:self];
[firstView setGallery:scrollerOne];
[secondView setGallery:scrollerTwo];
[thirdView setGallery:scrollerThree];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self scrollToMatch:scrollView];
}
#end
The UITabBarController gets notified (as the scroll view's delegate) when the user scrolls one of the instances, and then calls methods like scrollToMatch: to sync up the other two with the user's choice.
Is there something that can be done, using a many-to-one relationship on IBOutlet or something like that, to narrow this down to one instance so I'm not having to manage three scroll views? I tried keeping a single instance and moving the pointer from one view to the next using the UITabBarControllerDelegate methods (calling setGallery:nil on the current and setGallery:scrollerOne on the next each time it changed), but the scroller never moved to the other tabs.
Thanks in advance!
Certainly you should use only one instance of your scroller view. And it will works fine without any troubles. Use method setGallery: like you did, just ensure you add your singleScrollerForAll view to view of current controller in setGallery method:
-(void)setGallery:(UIView *)aScrollerView{
[self.view addSubview:aScrollerView];
}
and call:
[firstView setGallery:singleScrollerForAll];
or
[secondView setGallery:singleScrollerForAll];
and no need to do anything in other two controllers, because when you call addSubview: the subView will be automatically removed from previous superview.