Search Results

Search found 30 results on 2 pages for 'segue'.

Page 1/2 | 1 2  | Next Page >

  • Segue Popover won't behave properly

    - by CStreel
    I'm trying to use Segue to present then dismiss a Popover view a UIBarButtonItem is clicked. I've created a generic Segue that is not anchored to anything but the view and given it a name I've Anchored the UIBarButtonItem in the Interface Builder to: - (IBAction)clickedSettings:(id)sender { if(self.popSegue != nil) { [self.popSegue.popoverController dismissPopoverAnimated:YES]; } else { //Current says only a button may [self performSegueWithIdentifier:@"Settings" sender:sender]; } } But when ever i click the button to display the Segue it gives me an error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIStoryboardPopoverSegue must be presented from a bar button item or a view.' It doesn't even hit my -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender I've read the following questions on stack: iOS:How to dismiss Popover UIBarButtonItem + popover segue creates multiple popovers But i still get the same error. For the life of me i can't figure out what is going wrong

    Read the article

  • Perform Push Segue From a Tab View Controller

    - by user1416492
    I have a Tab Bar Controller App, the tab bar controller is forked into several "tab" view controller, in one of the view controller I want to redirect the user to an other view controller. I create a segue from that tab view controller to the destination view controller and given it an Identifer. And I call "performSegueWithIdentifier" in "viewDidAppear" to redirect the user. It works fine when the segue is "Modal", however since I want to retain the tabs, I want to call the segue through "Push". However, once I change the segue to "Push", it is not working anymore (it does not try to go to the destination view controller). The app did not crash on the simulator but just staying on the origin tab view controller.

    Read the article

  • error prepareForSegue between a viewController and a tableViewController

    - by beta
    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"My_TableView"]) { MyTableViewController *destViewController = segue.destinationViewController; destViewController.data = data; } } Hi, I have a problem doing a segue (modal) between a ViewController to a TableViewController. The name of the segue between the ViewController and the NavigationController is "My_TableView". Compiler gives me this error: unrecognized selector sent to instance 0x9275b50 what's the problem?

    Read the article

  • Dynamically showing TableView or DetailView

    - by Niels
    From my TableView I dynamically want to show either a TableView or a DetailView (new segue), based on the cell's content. I setup two segues from the TableView to different DetailViews and one segue from the TableViewCell to the TableView. I have almost completed the implementation using performSegueWithIdentifier: (see below), but there is one struggling issue remaining: after I call [self dismissModalViewControllerAnimated:YES]; on the DetailView it returns to an empty TableView . I assume because the Storyboard segue from the UITableViewCell is performed. By clicking the back button I return to my original (parent) TableView data. Any suggestions for this work? - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSLog(@"%s", __PRETTY_FUNCTION__); NSString *type = [[self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row] valueForKey:@"cell_type"]; NSLog(@"cell_type: %@", type); if([[segue identifier] isEqualToString:@"DetailSegue"]) { UIViewController *detailViewController = [segue destinationViewController]; detailViewController.game = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row]; } else if ... } else if([[segue identifier] isEqualToString:@"TableViewSegue"]){ if([type isEqualToString:@"TableView"]){ //Create child ViewController, a custom ViewController with custom initWithId:Title: CategoryViewController *categoryViewController = [[segue destinationViewController] initWithId:categoryId Title:categoryTitle]; } } }

    Read the article

  • Odd Segue Behaviour - Not Firing

    - by Zak
    So I've noticed some very weird behaviour from my program. Here's a simplified code snippet and then I'll explain what occurs when built and ran. -(void)viewDidLoad { [super viewDidLoad]; ... if (self.sampleBool) { [self performSegueWithIdentifier:@"mySegue" sender:self]; } else { // do stuff } } ... -(IBAction)myMethod:(UITapGestureRecognizer*)sender { ... [self performSegueWithIdentifier:@"mySegue" sender:self]; } The segue triggers via the UITapGestureRecognizer fine - so I know the segue is linked correctly. However, when self.sampleBool is true and performSegueWithIdentifier is called within viewDidLoad, the segue does not fire. Anyone have any guesses? Any help or advice is appreciated. Thanks

    Read the article

  • Dismiss Popover using Unwind Segue in Xcode Storyboard

    - by AlexR
    I am using Xcode 4.5 and the new iOS 6 feature to unwind segues. I am presenting a navigation view controller inside a popover which is presented programmatically from a bar button item: - (IBAction)configChartTapped:(id)sender { if (self.popover.isPopoverVisible) { [self.popover dismissPopoverAnimated:YES]; } else { UINavigationController *chartConfigNavigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"GrowthChartNavigationController"]; ConfigChartTypeViewController *configChartTypeViewController = (ConfigChartTypeViewController*) chartConfigNavigationController.topViewController; self.popover = [[UIPopoverController alloc]initWithContentViewController:chartConfigNavigationController]; self.popover.popoverContentSize = CGSizeMake(320, 500); self.popover.delegate = self; [self.popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } } Next to this method I have defined a target to unwind the segue (i.e. dismissing the popover)... - (IBAction)cancelConfig:(UIStoryboardSegue *)segue { // } ... and connected it to a cancel button in the navigation view controllers's navigation bar. Connecting the cancel bar button to the cancelConfig button worked fine in Xcode. However, when running the code, nothing happens when clicking on the Cancel button despite Xcode 4.5 should be supporting dismissing popovers when unwinding segues (according to the release docs). What did I miss? Thank you!

    Read the article

  • Application tried to present modally an active controller ios

    - by Matthew
    I was trying to set the ViewController with a parent view controller before it shows show that it can provide call backs, I done this using PrepareForSegue - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"newQuarter"]) { [segue.destinationViewController setParentViewController:self]; } } It crashed giving me the error message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller. So I tried using another method and set up a new view controller on the button touches up, - (IBAction) buttonClicked { NewViewController *newController = [[NewViewController alloc] init]; [newController setParentViewController:self]; [self presentViewController:newController animated:YES completion:nil]; } but with no luck it is still giving me the same error message, can anyone please advice? Thanks!

    Read the article

  • How to segue modal without losing tab bar controller

    - by Arian
    Okay, so I want to be able to have a TabBar Controller with two Tabs (like the template in Xcode), but inside the Second tab, I want to have a button that takes the view to a Third View Controller. I want the Third View Controller to have a back button to the Second Tab, I don't want the Third View to retain the TabBar, but when I go back to the Second Tab I want the TabBar to return. So this is what I actually did, and it doesn't work. I put a button in 2nd view and 3rd view, and I control clicked and dragged to the respective views, and clicked modal. Everything works, except when I go back to the 2nd view I lose the tab bar. Pictures of what I am talking about: http://s13.postimage.org/78gqghflj/Screen_Shot_2012_07_09_at_2_03_41_PM.png http://s16.postimage.org/gdwus4w6t/i_OS_Simulator_Screen_shot_Jul_9_2012_2_02_50_PM.png http://s10.postimage.org/5uq3ste7d/i_OS_Simulator_Screen_shot_Jul_9_2012_2_02_57_PM.png http://s8.postimage.org/gpmsx959x/i_OS_Simulator_Screen_shot_Jul_9_2012_2_03_54_PM.png

    Read the article

  • Error when passing data between views

    - by Kristoffer Bilek
    I'm using a plist (array of dictionaries) to populate a tableview. Now, when a cell i pressed, I want to pass the reprecented dictionary to the detail view with a segue. It's working properly to fill the tableview, but how do I send the same value to the detail view? This is my try: #import "WinesViewController.h" #import "WineObject.h" #import "WineCell.h" #import "WinesDetailViewController.h" @interface WinesViewController () @end @implementation WinesViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark - Table view data source - (void)viewWillAppear:(BOOL)animated { wine = [[WineObject alloc] initWithLibraryName:@"Wine"]; self.title = @"Vinene"; [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [wine libraryCount]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"wineCell"; WineCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Configure the cell... cell.nameLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Name"]; cell.districtLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"District"]; cell.countryLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Country"]; cell.bottleImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Image"]]; cell.flagImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Flag"]]; cell.fyldeImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Fylde"]]; cell.friskhetImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Friskhet"]]; cell.garvesyreImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Garvesyre"]]; return cell; } #pragma mark - Table view delegate - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"DetailSegue"]) { NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow]; WinesDetailViewController *winesdetailViewController = [segue destinationViewController]; //Here comes the error line: winesdetailViewController.winedetailName = [wine objectAtIndex:indexPath.row] valueForKey:@"Name"]; } } I get one error for: winesdetailViewController.winedetailName = [wine objectAtIndex:indexPath.row] valueForKey:@"Name"]; Use of undeclaired identifier: indexPath. did you mean NSIndexPath? I think I've missed something important here..

    Read the article

  • How to avoid Modal Storyboard infinite loop

    - by misthills
    I've written a number of iOS applications a year ago on an old version of Xcode. I've just started a new project and discovered the storyboard feature in the latest Xcode. It turns out this is perfect for the application I am writing as it consists of ~30 interlinked screens. My question is, how do I structure my storyboard and segues to allow my application to follow a circular path through my screens. I have seen a number of examples that simply segue screen 1 to screen 2 and then screen 2 to screen 1 using the modal option. This clearly works but when I debug an application built this way, it instantiates a new instance of each screen (view controller) for every segue performed. In the diagram below (apologies, I drew a nice picture but due to my newbie status, was not able to post it), how do I go from screen 1 to screen 2 to screen 3 and back to original screen 1 without creating a new instance? // Screen 1 --> Screen 2 --> Screen3 // ^ | // | | // +-------------------------+

    Read the article

  • Passing data back from detailViewController to Uitableview

    - by jsetting32
    I am currently at the issue where I have a UITableviewCell that needs to be updated. When the user presses on the uitableviewcell - THERES ONLY 1!!, the user is pushed to a UITABLEVIEWCONTROLLER where the user is allowed to select 1 of multiple cells with their own titles. I need to get the clicked tableviewcells title and pass the value back to the parentviewcontroller and update the 1 tableviewcell's name to the one the user clicked in the pushed uitableivewcontroller. Here is a picture of the parent viewcontroller... And heres the picture of the pushed viewcontroller.... I was told earlier yesterday that delegation would be needed but I am unsure what to do at this point :/. Heres some code I use in the parent viewcontroller... - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; ProblemTypes *view = [[ProblemTypes alloc] init]; [self.navigationController pushViewController:view animated:YES]; } I am also NOT USING storyboards, just a few xibs. Also heres the code for the pushedviewcontroller to pop to the parent viewcontroller when a cell is selected... #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; NSLog(@"Cell's text: %@",cell.textLabel.text); [self.navigationController popViewControllerAnimated:YES]; } Thank you guys!

    Read the article

  • How to display tab bar in UIViewController

    - by Akrambek
    I have created tabbar based project in MT and I have following flow in my storyboard; Tabbarcontroller -> 1) MainViewController -> CustomerViewController; 2) SettingViewController The problem I am having is that when I use PrepareForSegue function in CustomerViewController and pointing it to MainViewController. Tab Bar UI is missing from MainViewController. I know that if I point to TabBarController it is going to be fine. But I need to pass some data exactly to MainViewController. Is there any way to make it. I am new in iOS and monotouch. Any suggestion appreciate.

    Read the article

  • Add UIView and UILabel to UICollectionViewCell. Then Segue based on clicked cell index

    - by JetSet
    I am new to collection views in Objective-C. Can anyone tell me why I can't see my UILabel embedded in the transparent UIView and the best way to resolve. I want to also segue from the cell to several various UIViewControllers based on the selected index cell. I am using GitHub project https://github.com/mayuur/MJParallaxCollectionView Overall, in MJRootViewController.m I wanted to add a UIView with a transparency and a UILabel with details of the cell from a array. MJCollectionViewCell.h // MJCollectionViewCell.h // RCCPeakableImageSample // // Created by Mayur on 4/1/14. // Copyright (c) 2014 RCCBox. All rights reserved. // #import <UIKit/UIKit.h> #define IMAGE_HEIGHT 200 #define IMAGE_OFFSET_SPEED 25 @interface MJCollectionViewCell : UICollectionViewCell /* image used in the cell which will be having the parallax effect */ @property (nonatomic, strong, readwrite) UIImage *image; /* Image will always animate according to the imageOffset provided. Higher the value means higher offset for the image */ @property (nonatomic, assign, readwrite) CGPoint imageOffset; //@property (nonatomic,readwrite) UILabel *textLabel; @property (weak, nonatomic) IBOutlet UILabel *textLabel; @property (nonatomic,readwrite) NSString *text; @property(nonatomic,readwrite) CGFloat x,y,width,height; @property (nonatomic,readwrite) NSInteger lineSpacing; @property (nonatomic, strong) IBOutlet UIView* overlayView; @end MJCollectionViewCell.m // // MJCollectionViewCell.m // RCCPeakableImageSample // // Created by Mayur on 4/1/14. // Copyright (c) 2014 RCCBox. All rights reserved. // #import "MJCollectionViewCell.h" @interface MJCollectionViewCell() @property (nonatomic, strong, readwrite) UIImageView *MJImageView; @end @implementation MJCollectionViewCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) [self setupImageView]; return self; } - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) [self setupImageView]; return self; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ #pragma mark - Setup Method - (void)setupImageView { // Clip subviews self.clipsToBounds = YES; // Add image subview self.MJImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, IMAGE_HEIGHT)]; self.MJImageView.backgroundColor = [UIColor redColor]; self.MJImageView.contentMode = UIViewContentModeScaleAspectFill; self.MJImageView.clipsToBounds = NO; [self addSubview:self.MJImageView]; } # pragma mark - Setters - (void)setImage:(UIImage *)image { // Store image self.MJImageView.image = image; // Update padding [self setImageOffset:self.imageOffset]; } - (void)setImageOffset:(CGPoint)imageOffset { // Store padding value _imageOffset = imageOffset; // Grow image view CGRect frame = self.MJImageView.bounds; CGRect offsetFrame = CGRectOffset(frame, _imageOffset.x, _imageOffset.y); self.MJImageView.frame = offsetFrame; } - (void)setText:(NSString *)text{ _text=text; if (!self.textLabel) { CGFloat realH=self.height*2/3-self.lineSpacing; CGFloat latoA=realH/3; // self.textLabel=[[UILabel alloc] initWithFrame:CGRectMake(10,latoA/2, self.width-20, realH)]; self.textLabel.layer.anchorPoint=CGPointMake(.5, .5); self.textLabel.font=[UIFont fontWithName:@"HelveticaNeue-ultralight" size:38]; self.textLabel.numberOfLines=3; self.textLabel.textColor=[UIColor whiteColor]; self.textLabel.shadowColor=[UIColor blackColor]; self.textLabel.shadowOffset=CGSizeMake(1, 1); self.textLabel.transform=CGAffineTransformMakeRotation(-(asin(latoA/(sqrt(self.width*self.width+latoA*latoA))))); [self addSubview:self.textLabel]; } self.textLabel.text=text; } @end MJViewController.h // // MJViewController.h // ParallaxImages // // Created by Mayur on 4/1/14. // Copyright (c) 2014 sky. All rights reserved. // #import <UIKit/UIKit.h> @interface MJRootViewController : UIViewController{ NSInteger choosed; } @end MJViewController.m // // MJViewController.m // ParallaxImages // // Created by Mayur on 4/1/14. // Copyright (c) 2014 sky. All rights reserved. // #import "MJRootViewController.h" #import "MJCollectionViewCell.h" @interface MJRootViewController () <UICollectionViewDataSource, UICollectionViewDelegate, UIScrollViewDelegate> @property (weak, nonatomic) IBOutlet UICollectionView *parallaxCollectionView; @property (nonatomic, strong) NSMutableArray* images; @end @implementation MJRootViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //self.navigationController.navigationBarHidden=YES; // Fill image array with images NSUInteger index; for (index = 0; index < 14; ++index) { // Setup image name NSString *name = [NSString stringWithFormat:@"image%03ld.jpg", (unsigned long)index]; if(!self.images) self.images = [NSMutableArray arrayWithCapacity:0]; [self.images addObject:name]; } [self.parallaxCollectionView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - UICollectionViewDatasource Methods - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.images.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MJCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MJCell" forIndexPath:indexPath]; //get image name and assign NSString* imageName = [self.images objectAtIndex:indexPath.item]; cell.image = [UIImage imageNamed:imageName]; //set offset accordingly CGFloat yOffset = ((self.parallaxCollectionView.contentOffset.y - cell.frame.origin.y) / IMAGE_HEIGHT) * IMAGE_OFFSET_SPEED; cell.imageOffset = CGPointMake(0.0f, yOffset); NSString *text; NSInteger index=choosed>=0 ? choosed : indexPath.row%5; switch (index) { case 0: text=@"I am the home cell..."; break; case 1: text=@"I am next..."; break; case 2: text=@"Cell 3..."; break; case 3: text=@"Cell 4..."; break; case 4: text=@"The last cell"; break; default: break; } cell.text=text; cell.overlayView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f]; //cell.textLabel.text = @"Label showing"; cell.textLabel.font = [UIFont boldSystemFontOfSize:22.0f]; cell.textLabel.textColor = [UIColor whiteColor]; //This is another attempt to display the label by using tags. //UILabel* label = (UILabel*)[cell viewWithTag:1]; //label.text = @"Label works"; return cell; } #pragma mark - UIScrollViewdelegate methods - (void)scrollViewDidScroll:(UIScrollView *)scrollView { for(MJCollectionViewCell *view in self.parallaxCollectionView.visibleCells) { CGFloat yOffset = ((self.parallaxCollectionView.contentOffset.y - view.frame.origin.y) / IMAGE_HEIGHT) * IMAGE_OFFSET_SPEED; view.imageOffset = CGPointMake(0.0f, yOffset); } } @end

    Read the article

  • UIVIewController not released when view is dismissed

    - by Nelson Ko
    I have a main view, mainWindow, which presents a couple of buttons. Both buttons create a new UIViewController (mapViewController), but one will start a game and the other will resume it. Both buttons are linked via StoryBoard to the same View. They are segued to modal views as I'm not using the NavigationController. So in a typical game, if a person starts a game, but then goes back to the main menu, he triggers: [self dismissViewControllerAnimated:YES completion:nil ]; to return to the main menu. I would assume the view controller is released at this point. The user resumes the game with the second button by opening another instance of mapViewController. What is happening, tho, is some touch events will trigger methods on the original instance (and write status updates to them - therefore invisible to the current view). When I put a breakpoint in the mapViewController code, I can see the instance will be one or the other (one of which should be released). I have tried putting a delegate to the mainWindow clearing the view: [self.delegate clearMapView]; where in the mainWindow - (void) clearMapView{ gameWindow = nil; } I have also tried self.view=nil; in the mapViewController. The mapViewController code contains MVC code, where the model is static. I wonder if this may prevent ARC from releasing the view. The model.m contains: static CanShieldModel *sharedInstance; + (CanShieldModel *) sharedModel { @synchronized(self) { if (!sharedInstance) sharedInstance = [[CanShieldModel alloc] init]; return sharedInstance; } return sharedInstance; } Another post which may have a lead, but so far not successful, is UIViewController not being released when popped I have in ViewDidLoad: // checks to see if app goes inactive - saves. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActive) name:UIApplicationWillResignActiveNotification object:nil]; with the corresponding in ViewDidUnload: [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil]; Does anyone have any suggestions? EDIT: - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ NSString *identifier = segue.identifier; if ([identifier isEqualToString: @"Start Game"]){ gameWindow = (ViewController *)[segue destinationViewController]; gameWindow.newgame=-1; gameWindow.delegate = self; } else if ([identifier isEqualToString: @"Resume Game"]){ gameWindow = (ViewController *)[segue destinationViewController]; gameWindow.newgame=0; gameWindow.delegate = self;

    Read the article

  • Getting null value after adding objects to customClass

    - by Brian Stacks
    Ok here's my code first viewController.h @interface ViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegate> { NSMutableArray *twitterObjects; } @property (strong, nonatomic) IBOutlet UICollectionView *myCollectionView; Here is my viewController.m // // ViewController.m // MDF2p2 // // Created by Brian Stacks on 6/5/14. // Copyright (c) 2014 Brian Stacks. All rights reserved. // #import "ViewController.h" // add accounts framework to code #import <Accounts/Accounts.h> // add social frameworks #import <Social/Social.h> #import "TwitterCustomObject.h" #import "CustomCell.h" #import "DetailViewController.h" @interface ViewController () @end @implementation ViewController -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { //CustomCell * cell = (CustomCell*)sender; //NSIndexPath *indexPath = [_myCollectionView indexPathForCell:cell]; // setting an id for view controller DetailViewController *detailViewcontroller = segue.destinationViewController; //TwitterCustomObject *newCustomClass = [twitterObjects objectAtIndex:indexPath.row]; if (detailViewcontroller != nil) { // setting the custom customClass object //detailViewcontroller.myNewCurrentClass = newCustomClass; } } - (void)viewDidLoad { twitterObjects = [[NSMutableArray alloc]init]; [super viewDidLoad]; [self twitterAPIcall]; // Do any additional setup after loading the view, typically from a nib. } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 100; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { //UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath]; // initiate celli CustomCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath]; // add objects to cell if (cell != nil) { //TwitterCustomObject *newCustomClass = [twitterObjects objectAtIndex:indexPath.row]; //[cell refreshCell:newCustomClass.userName userImage:newCustomClass.userImage]; [cell refreshCell:@"Brian" userImage:[UIImage imageNamed:@"love.jpg"]]; } return cell; } -(void)twitterAPIcall { //create an instance of the account store from account frameworks ACAccountStore *accountStore = [[ACAccountStore alloc]init]; // make sure we have a valid object if (accountStore != nil) { // get the account type ex: Twitter, FAcebook info ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; // make sure we have a valid object if (accountType != nil) { // give access to the account iformation [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) { if (granted) { //^^^success user gave access to account information // get the info of accounts NSArray *twitterAccounts = [accountStore accountsWithAccountType:accountType]; // make sure we have a valid object if (twitterAccounts != nil) { //NSLog(@"Accounts: %@",twitterAccounts); // get the current account information ACAccount *currentAccount = [twitterAccounts objectAtIndex:0]; // make sure we have a valid object if (currentAccount != nil) { //string from twitter api NSString *requestString = @"https://api.twitter.com/1.1/friends/list.json"; // request the data from the request screen call SLRequest *myRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:requestString] parameters:nil]; // must authenticate request [myRequest setAccount:currentAccount]; // perform the request named myRequest [myRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { // check to make sure there are no errors and we have a good http:request of 200 if ((error == nil) && ([urlResponse statusCode] == 200)) { // make array of dictionaries from the twitter api data using NSJSONSerialization NSArray *twitterFeed = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil]; NSMutableArray *nameArray = [twitterFeed valueForKeyPath:@"users"]; // for loop that loops through all the post for (NSInteger i =0; i<[twitterFeed count]; i++) { NSString *nameString = [nameArray valueForKeyPath:@"name"]; NSString *imageString = [nameArray valueForKeyPath:@"profile_image_url"]; NSLog(@"Name feed: %@",nameString); NSLog(@"Image feed: %@",imageString); // get data into my mutable array TwitterCustomObject *twitterInfo = [self createPostFromArray:[nameArray objectAtIndex:i]]; //NSLog(@"Image feed: %@",twitterInfo); if (twitterInfo != nil) { [twitterObjects addObject:twitterInfo]; } } } }]; } } } else { // the user didn't give access UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"This app will only work with twitter accounts being allowed!." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:FALSE]; } }]; } } } -(TwitterCustomObject*)createPostFromArray:(NSArray*)postArray { // create strings to catch the data in NSArray *userArray = [postArray valueForKeyPath:@"users"]; NSString *myUserName = [userArray valueForKeyPath:@"name"]; NSString *twitImageURL = [userArray valueForKeyPath:@"profile_image_url"]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:twitImageURL]]]; // initiate object to put the data in TwitterCustomObject *twitterData = [[TwitterCustomObject alloc]initWithPostInfo:myUserName myImage:image]; NSLog(@"Name: %@",myUserName); return twitterData; } -(IBAction)done:(UIStoryboardSegue*)segue { } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end Here is my customObject class TwitterCustomClass.h // // TwitterCustomObject.h // MDF2p2 // // Created by Brian Stacks on 6/5/14. // Copyright (c) 2014 Brian Stacks. All rights reserved. // #import <Foundation/Foundation.h> @interface TwitterCustomObject : NSObject { } @property (nonatomic, readonly) NSString *userName; @property (nonatomic, readonly) UIImage *userImage; -(id)initWithPostInfo:(NSString*)screenName myImage:(UIImage*)myImage; @end TwitterCustomClass.m // // TwitterCustomObject.m // MDF2p2 // // Created by Brian Stacks on 6/5/14. // Copyright (c) 2014 Brian Stacks. All rights reserved. // #import "TwitterCustomObject.h" @implementation TwitterCustomObject -(id)initWithPostInfo:(NSString*)screenName myImage:(UIImage*)myImage { // initialize as object if (self = [super init]) { // use the data to be passed back and forth to the tableview _userName = [screenName copy]; _userImage = [myImage copy]; } return self; } @end The problem is I get the values in the method twitterAPIcall, I can get the names and image values or strings from the values. But in the (TwitterCustomObject*)createPostFromArray:(NSArray*)postArray method all values are coming up as null.I thought it got added with this line of code in the twitterAPIcall method [twitterObjects addObject:twitterInfo];?

    Read the article

  • SQL vs. Oracle Live Debate (AKA Smackdown!)

    - by Peter W. DeBetta
    A few years ago I was speaking at a conference in Raleigh, NC where Ted Neward and I found a fun way to promote a Java vs. .NET debate that was planned one evening. We stood in the middle of a crowd during one of the breaks and starting “arguing” about Java vs. .NET with one another. Our voice levels quickly raised and we ended it by slapping each other across the face with a glove to request a challenge. It was a great way to segue to our announcing of the actual debate planned later that evening....(read more)

    Read the article

  • SQL vs. Oracle Live Debate (AKA Smackdown!)

    - by Peter W. DeBetta
    A few years ago I was speaking at a conference in Raleigh, NC where Ted Neward and I found a fun way to promote a Java vs. .NET debate that was planned one evening. We stood in the middle of a crowd during one of the breaks and starting “arguing” about Java vs. .NET with one another. Our voice levels quickly raised and we ended it by slapping each other across the face with a glove to request a challenge. It was a great way to segue to our announcing of the actual debate planned later that evening....(read more)

    Read the article

  • Ios Parse Login

    - by user3806600
    I am programming an IOS app that will use parse to login a user. Using storyboard I have the login button connected to another view controller with the push segue. Whether the username and password are correct the button selection always goes to the new view controller. I might be doing this all wrong. Any help is appreciated. Here is my code: - (IBAction)signIn:(id)sender { [PFUser logInWithUsernameInBackground:self.emailField.text password:self.passwordField.text block:^(PFUser *user, NSError *error) { if (!error) { [self performSegueWithIdentifier:@"signIn" sender:nil]; } else { // The login failed. Check error to see why. } }]; }

    Read the article

  • iOS 6&7: Storyboard, master detail ViewController when detailViewController is dynamic

    - by Cam
    I'm building an app for iPhone, I want to use storyboard in XCode to do a simple selection from a tableView (let's call it master table view controller with couple rows) then through navigation it goes to next page and shows a detail view for that selection. I have in my code a base class representing my detailViewController, and have 2-3 driver classes of this base class representing what I want to show in detail view controller in second page, can someone give me an idea how to set destination viewController (detailViewController) dynamically to one of my child class based on the selected row in master view controller using storyboard? Usually you assign a class to destination class in storyboard for your detail view controller with using segue, but since my destination class could be a different (child class) how you set this in storyboard? Thank you, Kam

    Read the article

  • View controller/NIB architecture for non-navigation application with transitions?

    - by Ben
    I'm tinkering with an app that doesn't use the UINavigation root view control system, so I don't have natural ownership for each app "view". I essentially have two basic views, a document list view, and a document edit view. I'm playing with UIView animation for getting from a selected document to the edit view. I also have a toolbar that exists in both "views". Because I don't have UINavigation running the show for me, I have a tendency to just throw more and more stuff into one NIB and one view controller that owns the whole container. But now I'm trying to figure out how to segue from the document list view to the edit view if the edit view lives inside a different NIB, preserving the toolbar too. Anyone have thoughts or experience on app structures like this? I find the docs lacking on best practices around code/UI structure for anything except trivial one-screen apps or full-on navigation apps. Thanks!

    Read the article

  • How to specify the left, right, or title View button in XIB

    - by Sharen Eayrs
    I do not want to create a custom navigation bar. I am pushing a UIViewController and I want to customize how the navigation bar looks for that UIViewController In story board, we just specify the segue and a nav bar show up on the screen. We just drag and drop UIBarItem to the left and right. In XIB, the navigationBar simply doesn't show up. I can add navigation Item but the one I added is ignored. I've heard that there used to be an outlet called navigationItem but it's deprecated for reason I do not know. I can add UINavigationBar, however that would be adding my own custom bar. I want the navBar that's provided by UINavigationController.

    Read the article

  • Orientation issue while presenting Modal ViewController

    - by Jacky Boy
    Current scenario: Right now I am showing a UIViewController using a segue with the style Modal and presentation Sheet. This Modal gets its superview bounds change, in order to have the dimensions I want, like this: - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; self.view.superview.bounds = WHBoundsRect; } The only allowed orientations are UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight. Since the Modal has some TextFields and the keyboard would be over the Modal itself, I am changing its center so it moves a bit to the top. The problem: What I am noticing right now, is that I am unable to work with the Y coordinate. In order for it move vertically (remember it's on landscape) I need to work with the X. The problem is that when it's UIInterfaceOrientationLandscapeLeft I need to come with a negative X. And when it's UIInterfaceOrientationLandscapeRight I need to come with a positive X. So it seems that the X/Y Coordinate System is "glued" to the top left corner while in Portrait and when an orientation occurs, it's still there: What I have done So I have something like this: UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; NSInteger newX = 0.0f; if (orientation == UIInterfaceOrientationLandscapeLeft) { // Logic for calculating the negative X. } else { // Logic for calculating the positive X. } It works exactly like I want, but it seems a very fragile implementation. Am I missing something? Is this the expected behaviour?

    Read the article

  • iOS Switching an embedded view in storyboard

    - by Coyote6
    I have been trying to figure this out all day and I know it should be able to be done, but being new to iOS development using Objective-C and not Appcelerator I'm having newbie issues. What I am trying to accomplish is to have an embedded view in one of my other views, but to be able to switch which view is embedded through programming. I am using storyboards. When I tried to use the view container it displays the attached view, but I cannot attach multiple views to the container in the storyboard. I drew up an image, but to my annoyance I cannot post an image on here because I don't have enough "rep" points, so I posted it on my site: http://static.c6gx.com/images/iphone-embedded-views-diagram.jpg Later on I would like what appears to be a push segue, within that view container, but first I just want to be able to switch between embedded view 1, 2, 3, etc. Am I supposed to be using a view container to accomplish this, or some other type of controller? Then how would I call the transition to change the view? Thank you for any help you can provide.

    Read the article

1 2  | Next Page >