2013-03-18 2 views
0

Я новичок в программировании на телефоне. Скажите, пожалуйста, что я говорю о том, как перейти от одного взгляда к первому представлению в виде раскадровки. Код в блоке - это firstviewcontroller.m класс, который у меня есть сделана одна кнопка внутри, что я написал какое-то действие, которое я хочу перейти от firstviewcontroller, чтобы сначала просмотреть fisrt-представление stroyboard.Как перейти от одного взгляда к первому представлению раскадровки в iphone

#import"firstviewcontroller.h" 
    -(IBAction)show:(id)sender 
    { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    LXCollectionViewController *Controller = [storyboard instantiateViewControllerWithIdentifier:@"Controller "]; 
     [self presentModalViewController:loginController animated:YES]; 

    } 

Ниже код storybord код FirstView как я могу пойти с этой точки зрения XIb в storyborad view.programatically.above код не работает.

 #import "LXCollectionViewController.h" 
     #import "PlayingCard.h" 
     #import "PlayingCardCell.h" 
     @implementation LXCollectionViewController 
     - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
     { 
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
      if (self) { 
       // Custom initialization 
      } 
      return self; 
     } 
     - (void)awakeFromNib { 
      [super awakeFromNib]; 
      self.deck = [self constructsDeck]; 
     } 

     - (NSMutableArray *)constructsDeck { 
      NSMutableArray *theDeck = [NSMutableArray arrayWithCapacity:52]; 
      for (NSInteger theRank = 1; theRank <= 13; theRank++) { 
       // Spade 
       { 
        PlayingCard *thePlayingCard = [[PlayingCard alloc] init]; 
        thePlayingCard.suit = PlayingCardSuitSpade; 
        thePlayingCard.rank = theRank; 
        [theDeck addObject:thePlayingCard]; 
       } 
      } 
      return theDeck; 
     } 

     - (void)viewDidLoad { 
      // NSLog(@"%@",theDeck); 
      [super viewDidLoad]; 
      // Do any additional setup after loading the view. 
     } 
     #pragma mark - UICollectionViewDataSource methods 

     - (NSInteger)collectionView:(UICollectionView *)theCollectionView numberOfItemsInSection:(NSInteger)theSectionIndex { 
      switch (theSectionIndex) { 
       case 0: { 
        return [[self valueForKeyPath:@"[email protected]"] integerValue]; 
       } break; 
       default: { 
        return 0; 
       } break; 
      } 
     } 

- (UICollectionViewCell *)collectionView:(UICollectionView *)theCollectionView cellForItemAtIndexPath:(NSIndexPath *)theIndexPath { 
       NSInteger theSectionIndex = theIndexPath.section; 
       NSInteger theItemIndex = theIndexPath.item; 
       switch (theSectionIndex) { 
        case 0: { 
         PlayingCard *thePlayingCard = [self.deck objectAtIndex:theItemIndex]; 
         PlayingCardCell *thePlayingCardCell = [theCollectionView dequeueReusableCellWithReuseIdentifier:@"PlayingCardCell" forIndexPath:theIndexPath]; 
         thePlayingCardCell.playingCard = thePlayingCard; 
         return thePlayingCardCell; 
        } break; 
        default: { 
         return nil; 
        } break; 
       } 
      } 

      #pragma mark - LXReorderableCollectionViewDelegateFlowLayout methods 

      - (void)collectionView:(UICollectionView *)theCollectionView layout:(UICollectionViewLayout *)theLayout itemAtIndexPath:(NSIndexPath *)theFromIndexPath willMoveToIndexPath:(NSIndexPath *)theToIndexPath { 
       id theFromItem = [self.deck objectAtIndex:theFromIndexPath.item]; 
       [self.deck removeObjectAtIndex:theFromIndexPath.item]; 
       [self.deck insertObject:theFromItem atIndex:theToIndexPath.item]; 
      } 

Над кодом в IBAction не working.Please сказать мне, как подключить форму XIB к FirstView из раскадровки.

ответ

0

попытки ниже, если вы используете IOS SDK 6.1, как presentViewController осуждаются

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
LXCollectionViewController *objController = [sb instantiateViewControllerWithIdentifier:@"Controller"]; 
[objController setModalPresentationStyle:UIModalPresentationFullScreen]; 
[self presentViewController:objController animated:YES completion:nil]; 

, а также убедитесь, что вы указали идентификатор в viewControllers раскадровки в

+0

спасибо за предоставленную replay.Now и его не работает указанный идентификатор в средствах просмотра раскадровки. В общем, я использую контроллер коллекции в доске объявлений. – Mohammed

Смежные вопросы