| iOS Development Discussion on developing apps for the iOS platform. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Apr 27, 2011
Posts: 10
![]() |
*edit here is the complete project in a zip file. no Viruses from my end seeing how im uploading fro school. PLease feel free to look at the code but don't Steal it. Whouldnt be worth taking anyways (grumble amature coding)
http://www.mediafire.com/?ja4bfbcypspiaar Im sorry for any ambiguity through the title. Hello, my name is brad. im taking an xocde development class as an elective in college. for my final project i am creating a simple rpg style type game. this is where im running into errors. I have the first start screen which incompasses a FinalViewController.h .m and .xib file(a class view controller). when the first screen loads it prompts a view with two options(buttons). the first button loads a second class view controller(SaveViewController.h .m and .xib). This works fine. my Problem Occurs when i click another button in a diffrent view from the SaveViewController, which calls a method from FinalViewController. heres some code Snipplets i think might be helpful? From FinalViewController.m //this is the method used to remove the save class view and load the //Homeworld class view. i know the method works because when i call it // from inside the FinalViewController it works sucessfully. However when i // try and call it from inside SaveViewController. Code:
-(void)LoadHomeWorld{
[saveViewController.view removeFromSuperview];
[self.view insertSubview:homeWorldController.view atIndex:1];
}
Code:
heres the complete SaveView Controller .h and .m files
//
// SaveViewController.h
// Final
//
// Created by wctc on 4/25/11.
// Copyright 2011 WCTC. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CharData.h"
#import "FinalViewController.h"
@interface SaveViewController : UIViewController {
CharData *charData;
int SaveCount;
IBOutlet UIButton *loadButton;
IBOutlet UIPickerView *thePickerView;
IBOutlet FinalViewController* finalViewController;
NSMutableArray *charSaveArray;
int charSaveMarker;
IBOutlet UITextField *txtNewChar;
IBOutlet UIView *viewSplash;
IBOutlet UIView *viewNewChar;
}
-(NSString*)PassNewCharName;
- (IBAction)tapNewChar:(id)sender;
- (IBAction)tapCreateNewChar:(id)sender;
@end
Code:
//
// SaveViewController.m
// Final
//
// Created by wctc on 4/25/11.
// Copyright 2011 WCTC. All rights reserved.
//
#import "SaveViewController.h"
#import "FinalViewController.h"
@implementation SaveViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
#pragma mark - PickerView Implamentation - assigning colums
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
#pragma mark - PickerView Implamentation - Loading # rows needed
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [charSaveArray count];
}
#pragma mark - PickerView Implamentation - Filling Row Data
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [charSaveArray objectAtIndex:row];
}
#pragma mark - PickerView Implamentation - Delagation
// method to react to a picker view selection
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
charSaveMarker = row;
//NSLog(@"%@",[arrayAnswers objectAtIndex:0]);
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
charData = [[CharData alloc]init ];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (IBAction)tapNewChar:(id)sender {
[viewSplash addSubview:viewNewChar];
}
-(NSString*)PassNewCharName{
return txtNewChar.text;
}
- (IBAction)tapCreateNewChar:(id)sender {
[txtNewChar resignFirstResponder];
if ([txtNewChar.text length]<=0) {
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"No Name Entered" message:@"No name was Given. A name is Required." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[theAlert show]; [theAlert release];
}
if([txtNewChar.text length]<=1){
[finalViewController LoadHomeWorld];
}
}
@end
Last edited by brad35309; 04-27-2011 at 12:51 PM. |
| QUOTE Thanks | |
![]() Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
|
Am I missing something. I didn't see where you said what happens. Is there an error message, crash, or just nothing happens? What button are you specifically talking about and where is the code that it is connected to?
"my Problem Occurs when i click another button in a diffrent view from the SaveViewController, which calls a method from FinalViewController." I don't think that is considered to be normal. A view controller in iOS is used to take control of the whole screen. Calling a previous controller is possible but if you are dealing with a user interface item, you have to concerned what it is connected to, as in the previous controller, not the current one. Although tempted to look at your code, I don't normally click on links random suggested by people I don't know. CameraTime - Time lapse photography for novice and advanced users. When asking questions, post the version of your software. You'll receive better answers. Please post your results to the thread as it is good feedback.
|
| QUOTE Thanks | |
![]() Member Since: Apr 27, 2011
Posts: 10
![]() |
Code:
- (IBAction)tapCreateNewChar:(id)sender {
[txtNewChar resignFirstResponder];
if ([txtNewChar.text length]<=0) {
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"No Name Entered" message:@"No name was Given. A name is Required." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[theAlert show]; [theAlert release];
}
if([txtNewChar.text length]<=1){
[finalViewController LoadHomeWorld];
}
[finalViewController LoadHomeWorld]; this method is not working in this view. Quote:
Last edited by brad35309; 04-27-2011 at 09:37 PM. Reason: typo |
|||||
| QUOTE Thanks | ||||||
|
Member Since: Feb 25, 2009
Posts: 2,084
![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 Non-retina MBP, 2.6GHz i7, 8GB RAM, Antiglare Screen
|
I looked at all of your code..
It's coded in a style I don't personally prefer, but after reading it for a while and seeing what you are trying to accomplish these changes: 1) in SaveViewController.xib - delete the object in there that is a FinalViewController; it's not needed and creates an improper reference (it will instantiate a new FinalViewController rather then your FinalViewController you're attempting to work with). 2) In SaveViewController.m - in the method tapCreateNewChar change: Code:
if([txtNewChar.text length]<=1){
[finalViewController LoadHomeWorld];
}
Code:
if([txtNewChar.text length]>=1){
[finalViewController LoadHomeWorld];
}
I think that's all of the changes I made. appear to fix the problem. I'm attaching screen shots of the two changes in the xib files... I've also uploaded the screen I get to now after keying in a name (yes, that one button is off the screen so you'll need to adjust your nib a little...) My Macs: 2012 Non-Retina 15" MBP; Mac mini G4, 1.25 GHz, 512m ram (server); Late 2011 11" MBA, 1.8GHz i7, 4Gig Ram, 256Gig SSD, HD3000; Powerbook 12" G4 1.33GHz running Debian as a server; Apple TV (1080p version) |
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Use Finder Column View as default view | shahvikram123 | OS X - Operating System | 5 | 09-14-2008 10:27 AM |
| List view vs. Icon view - can't see all files | =^o.o^= | Switcher Hangout | 8 | 01-20-2007 06:39 PM |
| Finder/Folder View Options | geekboy2000 | OS X - Operating System | 2 | 12-03-2006 06:28 PM |
| Bridge Slide Show trouble | Benjamindaines | Images, Graphic Design, and Digital Photography | 2 | 10-01-2005 06:23 PM |
| Slide view instead of notes view in PowerPoint? | leemoreau | Switcher Hangout | 2 | 11-03-2004 05:23 PM |
All times are GMT -4. The time now is 09:04 PM.
Powered by vBulletin