2013-03-18 94 views
0

我是新来的我的手机programming.can aby身体告诉我如何从一个视图去故事板第一视图。下面的代码是firstviewcontroller.m类我有采取了一个按钮里面,我已经写了一些行动,我想从firstviewcontroller第一次查看stritboard的fisrt视图。如何从一个视图去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代码如何从这个厦门国际银行视图去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告诉我如何厦门国际银行的形式连接到故事板的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给了replay.Now还其不工作指定的标识符

+0

谢谢在故事板视图控制器手段中指定的标识符。实际上,我在故事板中使用了collectionview控制器。 – Mohammed 2013-03-18 09:19:18

相关问题