Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Still Trying to Switch Views

 
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  Entourage hangs while getting mail, CPU at  
Author Message
fripper

External


Since: Jan 29, 2005
Posts: 8



(Msg. 1) Posted: Wed Apr 15, 2009 12:32 am
Post subject: Still Trying to Switch Views
Archived from groups: comp>sys>mac>programmer>help (more info?)

I am having a devil of a time trying to figure out how to switch views in a
simple iPhone app. The app has two UIView Subclasses ... call them View1
and View2. I went to IB and created two xib files ... View1 and View2 and
populated them with buttons that I want to use to switch between the views
(the button on View1 will cause View2 to be displayed and the button on
View2 will cause View1 to be displayed). Back in View1.m I have a IBAction
routine to handle the touching of the button in View1 ... this sets up an
animation group:

[UIView beginanimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:View2];
[UIView
setAnimationDidStopSelector:@selector(transitionDidStop:funished:context:)];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:View2 cache:YES];
[UIView commitAnimations];

Now it seems to me that this should rotate View1 out of the way and display
View2 ... but it does not. The program compiles without error but when I
run it and touch the button on View1 nothing happens. I know it is
executing this code because I have used breakpoints and stepped through it.
Interstingly, if I change the forView parameter (in the
setAnimationTransition statement) to self and then touch the button View1
rotates and redisplays itself. For some reason I cannot get the program to
act on View2. I must not be doing something right ... as far as I know all
the xib components are connected properly.

Can someone help me ... perhaps by directing me to a tutorial that talks
about switching views in an app which has this general structure ... two
UIView subclasses and corresponding xib files.

Thanks very much.
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 2) Posted: Wed Apr 15, 2009 9:52 am
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <gs3o0202a9i RemoveThis @enews2.newsguy.com>,
"fripper" <young RemoveThis @indiana.edu> wrote:

> I am having a devil of a time trying to figure out how to switch views in a
> simple iPhone app. The app has two UIView Subclasses ... call them View1
> and View2. I went to IB and created two xib files ... View1 and View2 and
> populated them with buttons that I want to use to switch between the views
> (the button on View1 will cause View2 to be displayed and the button on
> View2 will cause View1 to be displayed). Back in View1.m I have a IBAction
> routine to handle the touching of the button in View1 ... this sets up an
> animation group:
>
> [UIView beginanimations:nil context:nil];
> [UIView setAnimationDuration:0.75];
> [UIView setAnimationDelegate:View2];
> [UIView
> setAnimationDidStopSelector:@selector(transitionDidStop:funished:context:)];
> [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
> forView:View2 cache:YES];
> [UIView commitAnimations];
>
> Now it seems to me that this should rotate View1 out of the way and display
> View2 ... but it does not. The program compiles without error but when I
> run it and touch the button on View1 nothing happens.

That's because you haven't actually done anything to change the view.
All these method calls describe how the animation should appear when the
change happens, but there's nothing in there to actually cause that
change. Before you commit the animations you've got to make some kind
of change that will be animated-- in this case, removing one view and
adding another one in its place.

Setting an animation delegate and a "did stop" selector just tells
UIView what method to call when the animation completes, it doesn't make
any animated changes occur.

--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
Back to top
Login to vote
Laurent Demaret

External


Since: Apr 18, 2009
Posts: 2



(Msg. 3) Posted: Sat Apr 18, 2009 5:21 pm
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

fripper <young RemoveThis @indiana.edu> wrote:

> [[self view] removeSubview:view1];
> [self addSubview:view2];
>
> but, of course, that doesn't work.
Maybee [someSuperView setContentView:zisView]; would help. If that's the
case may I urge you to buy Aaron Hillegas book "Cocoa Programming" as it
is the place I learned it ( well, it's also in Apple's doc but the book
is much easier to start with ). Chapter 29 title is "View swapping" ...

Best

ld
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 4) Posted: Sat Apr 18, 2009 5:23 pm
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <gsd82502e3n.DeleteThis@enews5.newsguy.com>,
"fripper" <young.DeleteThis@indiana.edu> wrote:

> I imagine that the view switching should look
> something like:
>
> [[self view] removeSubview:view1];
> [self addSubview:view2];
>
> but, of course, that doesn't work.

Maybe [view1 removeFromSuperview]? Is that not working for some reason?

--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
Back to top
Login to vote
fripper

External


Since: Jan 29, 2005
Posts: 8



(Msg. 5) Posted: Mon Apr 20, 2009 9:43 am
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Well, I went to Amazon to buy the book and find that the edition they show
(3rd) has only 26 chapters and none of them are titled "View Swapping"!
What edition are you referring to?

"Laurent Demaret" <ld RemoveThis @ideaslb.net> wrote in message
news:1iye29j.6m6qtaogcx81N%ld@ideaslb.net...
> fripper <young RemoveThis @indiana.edu> wrote:
>
>> [[self view] removeSubview:view1];
>> [self addSubview:view2];
>>
>> but, of course, that doesn't work.
> Maybee [someSuperView setContentView:zisView]; would help. If that's the
> case may I urge you to buy Aaron Hillegas book "Cocoa Programming" as it
> is the place I learned it ( well, it's also in Apple's doc but the book
> is much easier to start with ). Chapter 29 title is "View swapping" ...
>
> Best
>
> ld
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 6) Posted: Mon Apr 20, 2009 9:48 am
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <gsi2d60iim.DeleteThis@enews4.newsguy.com>,
"fripper" <young.DeleteThis@indiana.edu> wrote:

> SettingsView is the name of the xib file and its view outlet appears to be
> set properly. settingsViewController1 is a UIViewController object. After
> the code above I set the transition group code and then
>
> [self addSubview:settingsViewController1.view];
>
> [UIView commitAnimations];
>
> but it does not get past the assSubview statement ... it terminates with the
> "loaded the nib file but no view was set" message. I thought that when I
> went through the initWithNibName sequence above that it would set the view
> for settingViewController1 to the view that is in the nib file. Why is it
> telling me the view was not set.?

The only reason I know is exactly what it says-- that the view
controller's "view" outlet is not connected. I don't know what it looks
like when you bring it up but that's what the error means.

--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
Back to top
Login to vote
Laurent Demaret

External


Since: Apr 18, 2009
Posts: 2



(Msg. 7) Posted: Tue Apr 21, 2009 3:20 am
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

fripper <young.TakeThisOut@indiana.edu> wrote:

> Well, I went to Amazon to buy the book and find that the edition they show
> (3rd) has only 26 chapters and none of them are titled "View Swapping"!
> What edition are you referring to?
How strange ! My book is the 3rd edition and has 35 chapters, "Echange
de vues" is chapter 29 (french for View swapping). There is a web
address http://techstra.bignerdranch.com/ where you can put the page #
of the book in a field, hit the button and get a discussion with the
autor and others on your currently reading chapter.

Pasted from there :

> You are currently viewing page 355 in View Swapping.

It's a very well done translation and the page # fits well. this book
allowed me to get things done in Cocoa as I did not learn C at school
(there was no C or anything about computer learning at school back in
1975, in college and specialised class only). I also used the
"Programming in Objective)C 2.0" book of Stephan Kochan,
....
Ok, as I wanted to give you an amazone link so I've been there and found
that the excerpt they give is outdated ! It's writtten at the top and
you probably missed it :
> Just so you know...
>
> You originally clicked on the Paperback edition (2008) from
> Addison-Wesley Professional. You are looking at the Paperback edition
> (2001) from Addison-Wesley Professional. If you add this book to your
> cart, you'll get the edition you originally clicked on.

So you are a bit blind about this edition but, for me, it "worth the
bucks" ..

Have a nice day

Laurent
Back to top
Login to vote
Jim

External


Since: Apr 05, 2006
Posts: 117



(Msg. 8) Posted: Tue Apr 21, 2009 3:20 am
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2009-04-20, fripper <young RemoveThis @indiana.edu> wrote:
> Well, I went to Amazon to buy the book and find that the edition they show
> (3rd) has only 26 chapters and none of them are titled "View Swapping"!
> What edition are you referring to?

I have the 3rd edition and can confirm that chapter 29 is, indeed, 'View
Swapping'.

Jim
--
http://www.ursaMinorBeta.co.uk http://twitter.com/GreyAreaUK
Please help save Bletchley Park - sign the petition for
Government funding at: (open to UK residents and ex.pats)
http://petitions.number10.gov.uk/BletchleyPark/ Thank you.
Back to top
Login to vote
David Phillip Oster

External


Since: Jul 21, 2005
Posts: 1426



(Msg. 9) Posted: Tue Apr 21, 2009 7:49 am
Post subject: Re: Still Trying to Switch Views [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <gs3o0202a9i.RemoveThis@enews2.newsguy.com>,
"fripper" <young.RemoveThis@indiana.edu> wrote:

> I am having a devil of a time trying to figure out how to switch views in a
> simple iPhone app. The app has two UIView Subclasses ... call them View1
> and View2.

Create a new sample iPhone project. Choose the Utility style. Read the
source code.
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Multiple Views on a Document - I am working on developing a CAD style program. To implement this I am using the Cocoa Document-based Application I..

How to set up Tab Views in Cocoa - Being somewhat rusted in Cocoa, I'd like to find Tutorials , or hints about handling Tab Views. There is an example in....

Getting a list of available fonts - I'm trying to write an app that makes a list of all the available fonts and then presents them in a popup menu. On th...

"reserve()" Doesn't Help std::vector Speed Very Much - Hi, I recently discovered vectors and containers, and find they're much more convenient than valarrays which I have..

[Q] a nib file can't be loaded? - Hello. I have some problem with the example code of the book, "Building Cocoa Applications", O'Reilly. In t...

smb hostnames in CFURL - Hello, Is it possible to specify an smb hostname in a url? I'd like to do something like CFStringRef theUncPathRef =...
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]