2 UIWindow intr-o aplicatie, a folosit cineva?
  [ Ignoră ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Vreau sa prezint un controller cu view-ul semi-transparent, doar butoanele si alte elemente grafice sa aiba alpha 1.0, pot face asta cu:

self.view.backgroundColor [[UIColor clearColor] colorWithAlphaComponent0.3]

Problema e ca, daca il prezint modal view-ul nu e transparent, am inteles ca in momentul prezentarii modale, view-ul trebuie sa fie full-screen iar tot ce se afla sub el va fi transparent. In concluzie ce se vede sub el e UIWindow-ul principal.
Daca il adaug ca un subview merge cum trebuie dar nu ma ajuta pentru ca vreau ca acest view sa aiba controller-ul separat.
Am stat si m-am documentat mai bine si pot sa fac acest lucru daca folosesc alt Window.
In primul controller am ca proprietati un alt UIWindow si al 2-lea controller:

- (IBAction)test:(id)sender
{
    
if(self.window == nil)
    
{
        self
.window [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        if(
self.doi == nil)
            
self.doi [[[Doi alloc] initWithNibName: @"Doi" bundlenil] autorelease];
    
}
    self
.window.rootViewController self.doi;
    
[self.window makeKeyAndVisible];

Daca prezint controller-ul “doi” asa totul e ok, view-ul este semi-transparent iar cand vreau sa revin la primul, in loc sa folosesc

dismissModalViewController 

folosesc:

- (IBAction)test:(id)sender
{
    AppDelegate 
*delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
UIWindow *window delegate.window;
    
[window makeKeyAndVisible];


Intrebarea e daca ati folosit ceva asemanator si daca ati intampinat vreo problema?

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 1 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Am reusit sa gasesc echivalentul codului de mai sus fara sa mai folosesc alt UIWindow.
Am facut o delegate intre primul si al 2-lea controller apoi am implementarea urmatoare in primul controller:

- (IBAction)test:(id)sender
{
    NSLog
(@"%@",NSStringFromSelector(_cmd));
    
self.doi [[[Doi alloc] initWithNibName: @"Doi" bundlenil] autorelease];
    
self.doi.delegate self;
    
[self addChildViewControllerself.doi];
    
[self.view addSubview:self.doi.view];
    
[self.doi didMoveToParentViewControllerself];
}


#pragma mark Delegate Method

- (voidremoveFromParrent:(Doi *)sender
{
    NSLog
(@"%@",NSStringFromSelector(_cmd));
    
[sender willMoveToParentViewControllernil];
    
[sender.view removeFromSuperview];
    
[sender removeFromParentViewController];

In al 2-lea controller pentru dismiss am folosit:

- (IBAction)test:(id)sender
{
        NSLog
(@"%@",NSStringFromSelector(_cmd));

    
[self.delegate removeFromParrentself];

Merge doar in iOS5 dar poate e folositor cuiva.

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 2 ]
Avatar
RankRankRank
Member
Din: Ploiesti
Macuser din: 06.12.11

Cum se face delegate intre doua controlere ?

 Semnătură 


MacBook Pro 15”  i7 2.2GHz/ 16GB/ 500GB SSD ,  10.11
MacBook Air 13”  i5 1.3GHz/ 4GB/ 256GB SSD ,  10.11

Profil
 
  [ Ignoră ]   [ # 3 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Delegare normala parent/child controller. Parintele este atribuit ca delegat, adopta protocolul declarat de child controller, implementeaza metodele din protocol si cam atat smile

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 4 ]
Avatar
RankRankRank
Member
Din: Ploiesti
Macuser din: 06.12.11

aha , ma gandeam eu ca asa se face smile

 Semnătură 


MacBook Pro 15”  i7 2.2GHz/ 16GB/ 500GB SSD ,  10.11
MacBook Air 13”  i5 1.3GHz/ 4GB/ 256GB SSD ,  10.11

Profil
 
  [ Ignoră ]   [ # 5 ]
Avatar
RankRankRank
Member
Din: Ploiesti
Macuser din: 06.12.11

Pentru cei care nu stiu cum se face ( eram si eu printre voi acum citeva minute si foloseam AppDelegate )

Presupunem ca avem copilul DetaliiProduse si parintele RaftCustom
Ne propunem ca atunci cind apasam pe un buton , poza , etc din RaftCustom ( in cazul de fata un UITableViewController )  sa apara DetaliiProduse .

DetaliiProduse.h

#import <UIKit/UIKit.h>
@protocol DetaliiProdusDelegate;
@interface 
DetaliiProdus UIViewController
@property (nonatomicassignid<DetaliiProdusDelegatedelegate;

-(
IBAction)handleCloseButton:(id)sender;

@
end

@protocol DetaliiProdusDelegate
-(voiddetaliiProdusDidFinish:(DetaliiProdus*)viewController;
@
end 

DetaliiProduse.m

#import "DetaliiProdus.h"
@implementation DetaliiProdus
@synthesize delegate=_delegate;

- (
void)handleCloseButton:(id)sender {
    [self
.delegate detaliiProdusDidFinish:self];

}
.
.
.
.
@
end 

RaftCustom.h

#import <UIKit/UIKit.h>
#import "DetaliiProdus.h"
@interface RaftCustom UITableViewController<DetaliiProdusDelegate{
.
.
.
}

-(IBAction)btPoza:(id)sender ;

@
end 

RaftCustom.m

#import "RaftCustom.h"
@implementation RaftCustom
.
.
.
-(
IBAction)btPoza:(id)sender {
    DetaliiProdus 
*detaliuPoza [[DetaliiProdus alloc] init];
    
detaliuPoza.delegate self;
    
[self.navigationController pushViewController:detaliuPoza animated:YES];
}


- (void)detaliiProdusDidFinish:(DetaliiProdus *)viewController {
    [self
.navigationController popViewControllerAnimated:YES];
}
.
.
.
@
end 
 Semnătură 


MacBook Pro 15”  i7 2.2GHz/ 16GB/ 500GB SSD ,  10.11
MacBook Air 13”  i5 1.3GHz/ 4GB/ 256GB SSD ,  10.11

Profil
 
   
 
 
‹‹ UITableViewCell      timer countdown ››