Dans mon application, il y a 2 vues (bouton d'activation enfoncé), une pour afficher un lien Web et une autre pour afficher du texte. En première vue, j'ai pris un UIWebView et montré un lien web dedans. En 2ème vue j'ai pris UITextView n affichant du texte. Maintenant, comme je change de vue par bouton pressé parfois la vue web montre la vue de texte et parfois textview et la même chose se produit avec textview, signifient aléatoirement ces vues montrent n'importe quelle vue soit web ou texte. Les deux vues sont totalement différentes les unes des autres.Problème lors de la commutation des vues
Voici le code:
web.h
@interface web : UIViewController {
NSInteger bTag;
IBOutlet UIWebView *webShow;
}
@property(nonatomic,readwrite) NSInteger bTag;
@property (nonatomic, retain) IBOutlet UIWebView *webShow;
-(IBAction)menuButtonPressed:(id) sender;
@end
web.m
#import "help.h"
#import "web.h"
@implementation web
@synthesize bTag;
@synthesize webShow;
-(IBAction)menuButtonPressed:(id) sender
{
self.bTag=[sender tag];
switch (self.bTag)
{
case 1:
{
help *hv=[[help alloc] initWithNibName:nil bundle:nil];
hv.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:hv animated:YES];
[hv release];
break;
}
case 2:
{
web *wv=[[web alloc] initWithNibName:nil bundle:nil];
wv.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:wv animated:YES];
[wv release];
break;
}
default:
break;
}
}
-(void)viewWillAppear:(BOOL)animated
{
NSURL *url = [NSURL URLWithString:@"http://www.unicurd.com.sg/"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webShow loadRequest:request];
}
- (void)dealloc {
[super dealloc];
[webShow release];
}
@end
help.h
@interface help : UIViewController {
NSInteger bTag;
}
@property(nonatomic,readwrite) NSInteger bTag;
-(IBAction)menuButtonPressed:(id) sender;
@end
help.m
#import "help.h"
#import "web.h"
@implementation help
@synthesize bTag;
-(IBAction)menuButtonPressed:(id) sender
{
self.bTag=[sender tag];
switch (self.bTag)
{
case 1:
{
help *hv=[[help alloc] initWithNibName:nil bundle:nil];
hv.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:hv animated:YES];
[hv release];
break;
}
case 2:
{
web *wv=[[web alloc] initWithNibName:nil bundle:nil];
wv.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:wv animated:YES];
[wv release];
break;
}
default:
break;
}
}
Je l'affichage du texte dans help.xib en prenant UITextView.
Pouvez-vous montrer votre code? –
Je pense que ce que vous voulez est un UITabBarController – lukya