Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to accomplish a task but not successful even after trying for several days.

I have a tabbar which contains 3 tabs Friends, Chat, Settings.

  • Friends tab is just a subclass of uitableviewcontroller, when user tap on any user he will be jumped to second tab which is a chat tab.

  • The second tab(Chat) contains a uinavigationscontroller. This uinavigationcontroller it self contains two views 1> chatting interface, 2> ActiveChats which is a sub class of uitableviewcontroller to show a list of people to whom user is currently chatting with.

  • What I want is when user is on first tab and select any of her friend to chat she must be jumped on second tab and directly see chatting interface to chat with her friend. Problem is I have to set a root view controller for the navigationcontoller which is going to be pre-initialized but I want that chatting viewcontroller must be initialized every time when user select her friend, I also implemented a method initWithId which must take a selected person id and deliver msg to that particular person and save send & received messages.

  • part two of the problem, this chatting interface is root view controller but i also want a back button on it so when user tap on it, user will see ActiveChat view. This functionality is similar to WhatsApp, Viber or OneTeam applications.

Please help me out and avoid any silly mistakes i am a newbie. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
171 views
Welcome To Ask or Share your Answers For Others

1 Answer

I understanf the first part of your problem as you want to initialize the object of your class with the user-specific details . You have made the flow pretty complex , had it been a navigation-based , it would have been a lot easier for you.Now here , as per you requirement you have to initialize your class on each row clicked so you will have to make your "chatting interface " as a subview over your rootview of UINavigation or viewcontroller.view of the same and then in the viewDidLoad method of your rootView you can initialize your "chatting interface " everytime.

What i can infer from your other problem is that you want a back button to actually go to next page in UInavigationcontroller which is not pragmatic and doesn't make sense.Simply Push the nextview on to the navigationController.

From our comments, I saw the website and it is not a back button it has been customized to look as a back button.Apple doesn't allow such things and you may risk your app.Anyways you can do it this way :-

UIImage *image= [UIImage imageNamed:@"yourImage.png"]; //Here image shoulb be similar to backButton
UIButton *yourButton= [UIButton buttonWithType:UIButtonTypeCustom]; 
[yourButton setBackgroundImage:image forState:UIControlStateNormal]; 
yourButton.font = [UIFont boldSystemFontOfSize:10]; 
yourButton.frame = CGRectMake(0, 0, image.size.width, image.size.height); 
[yourButton addTarget:self action:@selector(yourTarget) forControlEvents:UIControlEventTouchUpInside];  self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:yourButton]; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...