I have a root view controller called A and a table view controller called B. And when the user selects a row in B it opens another ViewController. What I am trying to say is that when there is only one row is present in the tableview it should be open directly open in that ViewController. As data is coming in JSON format.
Asked
Active
Viewed 112 times
0
-
in your wish you can handle in multiple rows also ,it does not a problem – Anbu.Karthik Feb 01 '16 at 07:17
-
What should I do in the Delegate to open it directly. – Chandan Anand Feb 01 '16 at 07:20
-
you just check your json response if your array count is one then directly push to view controller otherwise push to tableview controller.. – yankit Patel Feb 01 '16 at 07:25
3 Answers
1
if(Option)
//NSLog(@"%@",Option);
{
if (Option.count==1)
{
NSDictionary *dict=(NSDictionary*)Option[0];
NSString *action=[dict valueForKey:@"action"];
if([action isEqualToString:@"m-deals-json"])
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle: nil];
UINavigationController *n=[mainStoryboard instantiateViewControllerWithIdentifier:@"DealsNavigation"];
DealsViewController *v=[mainStoryboard instantiateViewControllerWithIdentifier:@"DealsViewController"];
v.dict=dict;
self.window.rootViewController = n;
[self.window makeKeyAndVisible];
}
}
else
{
UINavigationController *n=[mainStoryboard instantiateViewControllerWithIdentifier:@"NavigationController"];
OffersViewController *v=[mainStoryboard instantiateViewControllerWithIdentifier:@"OffersViewController"];
self.window.rootViewController = n;
[self.window makeKeyAndVisible];
}
}

Chandan Anand
- 179
- 1
- 11
0
You can manage this with the check for your array count by which you displayed data in tableViewController called B. Like if it contains only one object, In that case just Push another ViewController without display tableViewController. and if array contain objects more than 1, then display tableViewController.

Ramkrishna Sharma
- 6,961
- 3
- 42
- 51

Surjeet Singh
- 11,691
- 2
- 37
- 54
0
you just check your json response if your array count is one then directly push to view controller otherwise push to tableview controller.
if(array.count==1)
{
////push to view controller
}
else
{
////push to tableview controller"
}

Simon McLoughlin
- 8,293
- 5
- 32
- 56

yankit Patel
- 331
- 1
- 12
-
@ChandanAnand Nobody will be able to tell you where it should be applied without seeing the code. Showing an image is pointless for this. This answer is more than enough for you to work with it. Nobody is going to write your app for you – Simon McLoughlin Feb 01 '16 at 11:07