Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 897909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:57:33+00:00 2026-05-15T14:57:33+00:00

im newbie developer and creating my first iphone app… and i have one little

  • 0

im newbie developer and creating my first iphone app… and i have one little problem 🙂

i switching in my program 2 views, secondView is over firstView, and when i press 2 times or more on button to show the SecondView iphone simulator stopping worling and if after i press to show the FirstView he still showing SecondView view :(…

and i need help how to make button to pressing one time only, and if after switch back to FirstView to can again press one time,and shows like presse,now it show pressed only when i tuch it,… i want like buttons in TabBar, and if i use the TabBar is more harder for me i dont know how to resize it to height and add custom background, and change the effect of pushed button

Thanks you very much and sorry for my bad english!.

here is what code i use to switching views with buttons

 //   FirstView.h
 #import <UIKit/UIKit.h>

@interface FirstView : UIViewController {

}

-(IBAction) goToSecondView:(id) sender;
-(IBAction) goToFirstView:(id) sender;

@end

//    FirstView.m
#import "FirstView.h"

#import "SecondView.h"

@implementation FirstView

SecondView *secondView;

-(IBAction) goToSecondView:(id) sender{
   secondView = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil]; 
   [self.view addSubview:secondView.view];
}

 -(IBAction) goToFirstView:(id) sender {      
    [secondView.view removeFromSuperview];
}

thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:57:33+00:00Added an answer on May 15, 2026 at 2:57 pm

    This:

    @implementation FirstView
    
    SecondView *secondView;
    

    … is most likely the source of your crash. You shouldn’t define instance variables in the implementation. The compiler may allow it but the runtime will be confused and the instance variable will not be properly retained.

    You should define it like:

    @interface FirstView : UIViewController {
        SecondView *secondView;
    }
    @property(nonatomic, retain) SecondView *secondView;
    

    …and use it like:

    -(IBAction) goToSecondView:(id) sender{
       UIView *newView = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
       self.secondView=newView;
       [newView release];
       [self.view addSubview:self.secondView.view];
    }
    

    For clarity you should also rename FirstView and SecondView to FirstViewController and SecondViewController because they are view controllers and not views themselves.

    More generally, what you are trying to do is dangerous and difficult. You don’t swap views by adding and removing them as subviews. You need to swap out view controller and their views using a UINavigationController or a UITabbarController. In Xcode File>New Project, there is a Navigation based project and a Tabbar based project templates. Either will provide you most of the code you need to implement a simple app using either controller.

    It will be well worth your time to spend a day learning how to use these controllers properly. With your current design, your app will break if it gets much more than two views.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

to all im newbie developer and trying to create my first iPhone app, sorry
I'm a newbie Cocoa developer and I'm developing my first application. I want to
Newbie here...can I write one program which incorporates .NET LINQ and also various Java
I have just done what appears to be a common newbie mistake : First
I'm a newbie spanish Rails developer. ¿Can u help me with a problem with
I'm a kinda newbie developer with a few years under my belt. Recently I
This is probably a really stupid newbie-sounding question to you developer type people, but
Sorry for the second newbie question, I'm a developer not a sysadmin so this
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Java Newbie here. I have a JFrame that I added to my netbeans project,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.