iOS share comman view on diffrent view controller - ios

I have implemented sliding menu code in iOS and want to share that single code for all view controller. is it possible ?? if yes then how can i implement this in my project ?
Can anyone help me for this ?
Here is a code I written in a view controller, and I want to share this code for all view controller.
(void)initslidingcode
{
//selected button background
_selectedbtnback=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"Menu_selection.png"]];
//end
//sliding code
slidestatus=0;
_menu=[[UIView alloc]initWithFrame:CGRectMake(-190,60,190,450)];
UIImageView *back=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"Menu_Bg.png"]];
back.frame=CGRectMake(0,-20,220,450);
[_menu insertSubview:back atIndex:0];
_menu.userInteractionEnabled=NO;
[_leftmenu setTarget:self];
[_leftmenu setAction:#selector(showmenu)];
UIImageView *img=[[UIImageView alloc] initWithFrame:CGRectMake(45,7,80,80)];
img.image=[UIImage imageNamed:#"profile.jpg"];
img.layer.cornerRadius=img.frame.size.width/2;
img.clipsToBounds=YES;
img.layer.borderWidth = 1.0f;
img.layer.borderColor = [UIColor greenColor].CGColor;
[_menu addSubview:img];
UILabel *username=[[UILabel alloc] initWithFrame:CGRectMake(0,88,175,18)];
username.text=#"Dilip Ingole";
username.textColor=[UIColor whiteColor];
username.textAlignment=NSTextAlignmentCenter;
[_menu addSubview:username];
UIImageView *line=[[UIImageView alloc] initWithFrame:CGRectMake(0,105,180,15)];
line.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line];
_activitybtn=[[UIButton alloc] initWithFrame:CGRectMake(0,110,180,37)];
_inboxbtn=[[UIButton alloc] initWithFrame:CGRectMake(0,150,180,37)];
_nutritionchartbtn=[[UIButton alloc] initWithFrame:CGRectMake(0,190,180,37)];
_trainingplanbtn=[[UIButton alloc] initWithFrame:CGRectMake(0,230,180,37)];
_heartbeatbtn=[[UIButton alloc] initWithFrame:CGRectMake(0,270,180,37)];
_friends=[[UIButton alloc] initWithFrame:CGRectMake(0,310,180,37)];
_goalsbtn=[[UIButton alloc] initWithFrame:CGRectMake(0,350,180,37)];
_goshopbtn=[[UIButton alloc] initWithFrame:CGRectMake(0,390,180,37)];
[_activitybtn setTitle:#"Activity" forState:UIControlStateNormal];
_activitybtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
[_activitybtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_activitybtn addTarget:self action:#selector(openactivity) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Activity_icon.png"];
_activitybtn.titleEdgeInsets = UIEdgeInsetsMake(0, 50, 0,0);
[_activitybtn addSubview:img];
[_menu addSubview:_activitybtn];
UIImageView *line1=[[UIImageView alloc] initWithFrame:CGRectMake(0,145,180,15)];
line1.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line1];
[_inboxbtn setTitle:#"Inbox" forState:UIControlStateNormal];
[_inboxbtn.titleLabel setTextAlignment:NSTextAlignmentLeft];
[_inboxbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_inboxbtn addTarget:self action:#selector(openinbox) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Msgbox_icon.png"];
_inboxbtn.titleEdgeInsets = UIEdgeInsetsMake(0,0,0,30);
[_inboxbtn addSubview:img];
[_menu addSubview:_inboxbtn];
UIImageView *line2=[[UIImageView alloc] initWithFrame:CGRectMake(0,183,180,15)];
line2.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line2];
[_nutritionchartbtn setTitle:#"Nutrition Chart" forState:UIControlStateNormal];
[_nutritionchartbtn.titleLabel setTextAlignment:NSTextAlignmentLeft];
[_nutritionchartbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_nutritionchartbtn addTarget:self action:#selector(opennutritionchart) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Nutrition_Icon.png"];
_nutritionchartbtn.titleEdgeInsets = UIEdgeInsetsMake(0,45, 0,0);
[_nutritionchartbtn addSubview:img];
[_menu addSubview:_nutritionchartbtn];
UIImageView *line3=[[UIImageView alloc] initWithFrame:CGRectMake(0,223,180,15)];
line3.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line3];
[_trainingplanbtn setTitle:#"Training Plan" forState:UIControlStateNormal];
[_trainingplanbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_trainingplanbtn addTarget:self action:#selector(opentrainingplan) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Training_icon.png"];
_trainingplanbtn.titleEdgeInsets = UIEdgeInsetsMake(0, 30, 0,0);
[_trainingplanbtn addSubview:img];
[_menu addSubview:_trainingplanbtn];
UIImageView *line4=[[UIImageView alloc] initWithFrame:CGRectMake(0,263,180,15)];
line4.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line4];
[_heartbeatbtn setTitle:#"Heart Beat" forState:UIControlStateNormal];
[_heartbeatbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_heartbeatbtn addTarget:self action:#selector(openheartbeat) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"heart_icon.png"];
_heartbeatbtn.titleEdgeInsets = UIEdgeInsetsMake(0,20, 0,0);
[_heartbeatbtn addSubview:img];
[_menu addSubview:_heartbeatbtn];
UIImageView *line5=[[UIImageView alloc] initWithFrame:CGRectMake(0,303,180,15)];
line5.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line5];
[_friends setTitle:#"Friends" forState:UIControlStateNormal];
[_friends setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_friends addTarget:self action:#selector(openfriends) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Friends_icon.png"];
_friends.titleEdgeInsets = UIEdgeInsetsMake(0,0, 0,5);
[_friends addSubview:img];
[_menu addSubview:_friends];
UIImageView *line6=[[UIImageView alloc] initWithFrame:CGRectMake(0,343,180,15)];
line6.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line6];
[_goalsbtn setTitle:#"Goals" forState:UIControlStateNormal];
[_goalsbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_goalsbtn addTarget:self action:#selector(opengoals) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Goals_icon.png"];
_goalsbtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0,25);
[_goalsbtn addSubview:img];
[_menu addSubview:_goalsbtn];
UIImageView *line7=[[UIImageView alloc] initWithFrame:CGRectMake(0,383,180,15)];
line7.image=[UIImage imageNamed:#"menu_divided_line.png"];
[_menu addSubview:line7];
[_goshopbtn setTitle:#"Go Shop" forState:UIControlStateNormal];
[_goshopbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
[_goshopbtn addTarget:self action:#selector(opengoshop) forControlEvents:UIControlEventTouchUpInside];
img=[[UIImageView alloc] initWithFrame:CGRectMake(2, 1, 40, 40)];
img.image=[UIImage imageNamed:#"Shoping Icon.png"];
_goshopbtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0,0);
[_goshopbtn addSubview:img];
[_menu addSubview:_goshopbtn];
//sliding
}
-(void)showmenu
{
[_menu removeFromSuperview];
_menu.userInteractionEnabled=YES;
if (slidestatus==0)
{
slidestatus=1;
[UIView animateWithDuration:0.5f animations:^{
_menu.frame = CGRectMake(0,60,190,450);
}];
}
else
{
slidestatus=0;
[UIView animateWithDuration:0.5f animations:^{
_menu.frame = CGRectMake(-190,60,190,450);
}];
}
[self.view insertSubview:_menu atIndex:100];
}
-(void)openactivity
{
//open activity controller
}
-(void)openinbox
{
[_inboxbtn setImage:[UIImage imageNamed:#"Menu_selection.png"] forState:UIControlStateHighlighted];
//open activity controller
}
-(void)opennutritionchart
{
//open activity controller
}
-(void)opentrainingplan
{
//open activity controller
}
-(void)openheartbeat
{
//open activity controller
NSLog(#"heart controller");
}
-(void)openfriends
{
//open activity controller
}
-(void)opengoals
{
//open activity controller
}
-(void)opengoshop
{
//open activity controller
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
slidestatus=0;
[UIView animateWithDuration:0.5f animations:^{
_menu.frame = CGRectMake(-190,60,190,450);
}];
}

This guys did wonderful job with side menu.
There is also integrations instructions.
MVYSideMenu
Anyway, To achieve your task, consider to manage your side menu from the AppDelegate and consider to add the side menu on top of the appDelegate.window same as UITabBarController, for example.

Related

UINavigationController centered button using obj-c

I'm trying to add a centered button in my navbar header, confused as to how I can do it
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *meImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:#"%#/me.png", kSelfBundlePath]];
UIBarButtonItem *meButton = [[UIBarButtonItem alloc] initWithImage:meImage style:UIBarButtonItemStylePlain target:self action:#selector(twitterButton)];
[self.titleView //i read this can be used to like set it but i havent been able to figure it out
help would be appreciated, pretty new
check this code
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
container.backgroundColor = [UIColor clearColor];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setFrame:CGRectMake(0, 0, 44, 44)];
[btn setBackgroundImage:[UIImage imageNamed:#"button0.png"] forState:UIControlStateNormal];
[btn addTarget:self action:#selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
[btn setShowsTouchWhenHighlighted:YES];
[buttonContainer addSubview:button0];
//add your spacer images and button1 and button2...
self.navigationItem.titleView = container;
You can try like this way
UIView *topView = [[UIView alloc]initWithFrame:CGRectZero];
UIButton * button = [[UIButton alloc]initWithFrame:CGRectZero];
[button addTarget:self action:#selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:#"Title here" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button sizeToFit];
[topView addSubview:button];
[topView sizeToFit];
self.navigationItem.titleView = topView;
-(void)buttonAction:(Id) sender {
NSLog(#"button clicked");
}
I think its pretty straight, you can use titleView property of UINavigationItem :
-(void)addCenterButton {
UIImage *meImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:#"%#/me.png", kSelfBundlePath]];
UIButton *button = [[UIButton alloc] initWithFrame::CGRectMake(0, 0, 40, 20)];
[button setImage:meImage forState:UIControlStateNormal];
[button addTarget:self action:#selector(twitterButton) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView = button;
}

Space between uibarbuttons in navigation bar, Xcode 6.1

I have tried almost all answers here, How to remove the blank space between the two uibarbuttons shown below the code i use is
UIButton *backBTN= [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[backBTN addTarget:self action:#selector(backACT:) forControlEvents:UIControlEventTouchUpInside];
[backBTN setBackgroundImage:[UIImage imageNamed:#"menu_icon.png"] forState:UIControlStateNormal];
UIBarButtonItem *backkb = [[UIBarButtonItem alloc] initWithCustomView:backBTN];
// self.navigationItem.leftBarButtonItem = backkb;
UIButton *homeBTN= [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[homeBTN addTarget:self action:#selector(homeACT:) forControlEvents:UIControlEventTouchUpInside];
[homeBTN setBackgroundImage:[UIImage imageNamed:#"logout_btn.png"] forState:UIControlStateNormal];
UIBarButtonItem *btnhome = [[UIBarButtonItem alloc] initWithCustomView:homeBTN];
// btnhome.imageInsets = UIEdgeInsetsMake(-10, 0, 0, 0);
[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects: backkb, btnhome, nil]];
self.navigationItem.hidesBackButton = YES;
Try this,
// Create a UIView to add both buttons
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
UIButton *backBTN= [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[backBTN addTarget:self action:#selector(backACT:) forControlEvents:UIControlEventTouchUpInside];
[backBTN setBackgroundImage:[UIImage imageNamed:#"menu_icon.png"] forState:UIControlStateNormal];
//Add button to UIView
[leftView addSubview:backBTN];
UIButton *homeBTN= [[UIButton alloc] initWithFrame:CGRectMake(30, 0, 30, 30)];
[homeBTN addTarget:self action:#selector(homeACT:) forControlEvents:UIControlEventTouchUpInside];
[homeBTN setBackgroundImage:[UIImage imageNamed:#"logout_btn.png"] forState:UIControlStateNormal];
//Add button to UIView
[leftView addSubview:homeBTN];
//Set UIView as CustomView for bar button
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:leftView];
[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects: leftBarButton, nil]];
self.navigationItem.hidesBackButton = YES;
I have tried this and got output as
used some background colour to know the borders

Custom navigation bar back button hit area

I have implement custom back Navigation bar button.
Codes:
-(UIBarButtonItem*) logicToAddBackButton {
UIImageView *imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"UiNavigationBack"]];
UILabel *label=[[UILabel alloc] init];
[label setTextColor:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0]];
[label setText:#"Home"];
[label sizeToFit];
int space=6;
label.frame=CGRectMake(imageView.frame.origin.x+imageView.frame.size.width+space, label.frame.origin.y, label.frame.size.width, label.frame.size.height);
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, label.frame.size.width+imageView.frame.size.width+space, imageView.frame.size.height)];
view.bounds=CGRectMake(view.bounds.origin.x+8, view.bounds.origin.y-1, view.bounds.size.width, view.bounds.size.height);
[view addSubview:imageView];
[view addSubview:label];
UIButton *button=[[UIButton alloc] initWithFrame:view.frame];
[button addTarget:self action:#selector(eventBack) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:button];
[UIView animateWithDuration:0.33 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
label.alpha = 0.0;
CGRect orig=label.frame;
label.frame=CGRectMake(label.frame.origin.x+25, label.frame.origin.y, label.frame.size.width, label.frame.size.height);
label.alpha = 1.0;
label.frame=orig;
} completion:nil];
UIBarButtonItem *backButton =[[UIBarButtonItem alloc] initWithCustomView:view];
return backButton;
}
self.navigationItem.leftBarButtonItem = [self logicToAddBackButton];
This is how it look and work fine according to the logic.
Issue: If we click on first half of arrow, the back button do not respond.
Please suggest on this.
Try to set to your button:
button.contentEdgeInsets = UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)
I think you miscalculating frame somewhere.
Why don't you add UIButton instead? It will be much easier, but without label animation.
UIButton *button = [[UIButton alloc] init];
[button addTarget:self action:#selector(eventBack:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:#"Home" forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:#"UiNavigationBack"] forState:UIControlStateNormal];
[button setTitleColor:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
[button sizeToFit];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:button];
return backButton;

ChildViewController not able to modify its UI after creation

I have a view controller which is being added as a child view controller. The problem is that after the child controller creates its view, I am not able to modify it.
It loads everything properly, but when I want to hide a text field on clicking a button (textfield.hidden = YES), nothing happens!
This is my loadView :
-(void)loadView {
self.waitingPopup = [[WaitingPopupViewController alloc]initWithLabel:#"loading salon"];
self.view=[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
// self.view.frame=CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height);
scrollableTable=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollableTable.delegate=self;
scrollableTable.dataSource=self;
[self.view addSubview:scrollableTable];
headerHolder=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-44)];
//creating and adding backgroundImage view container and setting the image
// saloonHomeImage.backgroundColor = [UIColor grayColor];
saloonHomeImage.frame=CGRectMake(self.view.frame.origin.x, 0, self.view.frame.size.width, self.view.frame.size.height);
saloonHomeImage.contentMode = UIViewContentModeScaleAspectFill;
//[saloonHomeImage setBackgroundColor:[UIColor redColor]];
[headerHolder setBackgroundColor:[UIColor grayColor]];
[headerHolder addSubview:saloonHomeImage];
//creating and adding saloonheader label
saloonLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 32, self.view.frame.size.width, 48)];
saloonLabel.text=#"";
saloonLabel.textAlignment=NSTextAlignmentCenter;
[saloonLabel setTextColor:[UIColor whiteColor]];
[saloonLabel setFont:[UIFont fontWithName:#"vevey" size:48]];
[headerHolder addSubview:saloonLabel];
//creating and adding book appointment button
UIButton *bookAppointmentButton=[UIButton buttonWithType:UIButtonTypeSystem];
NSLog(#"%f", self.view.frame.size.height-97.5);
bookAppointmentButton.frame=CGRectMake(self.view.frame.origin.x, self.view.frame.size.height-97.5, 216, 53);
[bookAppointmentButton setBackgroundImage:[UIImage imageNamed:#"bg-left.png"] forState:UIControlStateNormal];
[bookAppointmentButton setTitle:#"BOOK APPOINTMENT" forState:UIControlStateNormal];
[bookAppointmentButton addTarget:self action:#selector(bookAppointmentAction) forControlEvents:UIControlEventTouchUpInside];
[bookAppointmentButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[headerHolder addSubview:bookAppointmentButton];
UIButton *callButton=[UIButton buttonWithType:UIButtonTypeSystem];
callButton.frame=CGRectMake(216, self.view.frame.size.height-97.5, self.view.frame.size.width-216, 53);
[callButton setBackgroundImage:[UIImage imageNamed:#"bg-right.png"] forState:UIControlStateNormal];
[callButton addTarget:self action:#selector(callButtonAction) forControlEvents:UIControlEventTouchUpInside];
[callButton setTitle:#"CALL" forState:UIControlStateNormal];
[callButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[headerHolder addSubview:callButton];
[self getSalonDetails];
loading=[[UIImageView alloc] init];
loading.frame=CGRectMake(130,200,40,36);
[loading setBackgroundColor:[UIColor clearColor]];
loading.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"spinner-1.png"],
[UIImage imageNamed:#"spinner-2.png"],
[UIImage imageNamed:#"spinner-3.png"],
[UIImage imageNamed:#"spinner-4.png"],
[UIImage imageNamed:#"spinner-5.png"],
[UIImage imageNamed:#"spinner-6.png"],
[UIImage imageNamed:#"spinner-7.png"],
[UIImage imageNamed:#"spinner-8.png"],[UIImage imageNamed:#"spinner-9.png"],nil];
loading.animationDuration = 1.0f;
loading.animationRepeatCount = 0;
[loading startAnimating];
[self.view addSubview:loading];
loadingText = [[UILabel alloc]initWithFrame:CGRectMake(90, 240, 200, 40)];
loadingText.text = #"loading salon";
[loadingText setFont:GOTHIC_FONT(22)];
[loadingText setTextColor:[UIColor whiteColor]];
[self.view addSubview:loadingText];
articles=[Model getArticles];
}
- (void) getSalonDetails{
[[MyDataModel sharedDataModel] getSalonDetails];
}
This is the delegate method which is trying to set some fields hidden. This delegate is called when an NSURLSession call completes successfully. The control comes here as per logs but nothing gets hidden. When I add a breakpoint and inspect the fields, every object is shown as nil. If this class is used as the main view controller, I've found everything works. On making it a child view, nothing works.
-(void)salonDetailsRecievedDelegate:(BOOL)success andStatusCode:(int)statusCode{
[loading stopAnimating];
self.loading.hidden = YES;
self.loadingText.hidden = YES;
saloonLabel.text = #"this is texT";
if(success){
//
}
}
What I think here is that salonDetailsRecievedDelegate isn't called from the main thread, try any of the following:
1) call it in the main thread from your model as follows:
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate salonDetailsRecievedDelegate:success andStatusCode:status];
});
2) change its implementation as follows:
-(void)salonDetailsRecievedDelegate:(BOOL)success andStatusCode:(int)statusCode{
dispatch_async(dispatch_get_main_queue(), ^{
[loading stopAnimating];
self.loading.hidden = YES;
self.loadingText.hidden = YES;
saloonLabel.text = #"this is texT";
if(success){
//
}
});
}

iOS : Cannot click the right side of UINavigationItem

-(void )SetNavBarView{
searchBarBtn.hidden=YES;
UIView *NavBarView ;
NavBarView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
btn1.titleLabel.font=[UIFont systemFontOfSize:14];
[btn1 setBackgroundImage:[UIImage imageNamed:#"list.png"] forState:UIControlStateSelected];
[btn1 setBackgroundImage:[UIImage imageNamed:#"nine_grid.png"] forState:UIControlStateNormal];
btn1.tag=10;
[btn1 addTarget:self action:#selector(btnBarClick:) forControlEvents:UIControlEventTouchUpInside];
[NavBarView addSubview:btn1];
UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(45, 0, 44, 44)];
btn2.titleLabel.font=[UIFont systemFontOfSize:14];
[btn2 setBackgroundImage:[UIImage imageNamed:#"map.png"] forState:UIControlStateNormal];
btn2.tag=11;
[btn2 addTarget:self action:#selector(btnBarClick:) forControlEvents:UIControlEventTouchUpInside];
[NavBarView addSubview:btn2];
UILabel *labtitle=[[UILabel alloc]initWithFrame:CGRectMake(95, 0, 120, 44)];
labtitle.text=NSLocalizedString(#"people_nearby", nil);
labtitle.textColor=[UIColor whiteColor];
labtitle.backgroundColor=[UIColor clearColor];
labtitle.textAlignment=UITextAlignmentCenter;
labtitle.font=[UIFont boldSystemFontOfSize:20.0];
[NavBarView addSubview:labtitle];
UIButton *btn3 = [[UIButton alloc] initWithFrame:CGRectMake(135, 0, 95, 44)];
btn3.tag=12;
[btn3 addTarget:self action:#selector(btnBarClick:) forControlEvents:UIControlEventTouchUpInside];
[NavBarView addSubview:btn3];
arrowImage=[[UIImageView alloc]initWithFrame:CGRectMake(75, 16, 10, 10)];
arrowImage.image=[UIImage imageNamed:#"arrow_down.png"];//arrow_down.png
[btn3 addSubview:arrowImage];
UIButton *btn4 = [[UIButton alloc] initWithFrame:CGRectMake(230, 0, 44, 44)];
btn4.titleLabel.font=[UIFont systemFontOfSize:14];
[btn4 setBackgroundImage:[UIImage imageNamed:#"ic_action_search.png"] forState:UIControlStateNormal];
btn4.tag=13;
[btn4 addTarget:self action:#selector(btnBarClick:) forControlEvents:UIControlEventTouchUpInside];
[NavBarView addSubview:btn4];
// [bubble stretchableImageWithLeftCapWidth:20 topCapHeight:14]
UIButton *btn5 = [[UIButton alloc] initWithFrame:CGRectMake(275, 0, 44, 44)];
btn5.backgroundColor=[UIColor redColor];
[btn5 setBackgroundImage:[UIImage imageNamed:#"location.png" ] forState:UIControlStateNormal];
btn5.tag=14;
[btn5 addTarget:self action:#selector(btnBarClick:) forControlEvents:UIControlEventTouchUpInside];
[NavBarView addSubview:btn5];
NavBarView.hidden=NO;
// [self.view addSubview:NavBarView];
self.navigationItem.titleView=NavBarView;
}
I have a UINavigationItem , which has five buttons. The fifth button btn5 can only click the left side, but the right of the btn5 cannot be clicked. ( Size of the button is 44 x 44 )
It's because of the size of UINavigationBarItem, it will by default leave a 14px around both sides. If you give a background color to your first button, then you see that space.

Resources