Problem: no circle showing up(Xcode 7)

#1

Hi there… me again.
I do as the example code does but there’s no circle on the screen. Just still a red screen??
My code:

BNRHypnosister.h

#import <UIKit/UIKit.h>

@interface BNRHypnosisView : UIView

@end

BNRHypnosister.m

[code]#import “BNRHypnosisView.h”

@implementation BNRHypnosisView

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.

  • (void)drawRect:(CGRect)rect {
    CGRect bounds = self.bounds;
    CGPoint center;
    center.x = bounds.origin.x + bounds.size.width / 2.0;
    center.y = bounds.origin.y + bounds.size.height / 2.0;

    float radius = (MIN(bounds.size.width, bounds.size.height) / 2.0);
    UIBezierPath *path = [[UIBezierPath alloc] init];
    [path addArcWithCenter:center
    radius:radius
    startAngle:0.0
    endAngle:M_PI * 2.0
    clockwise:YES];
    [[UIColor lightGrayColor] setStroke];
    [path stroke];
    }

@end
[/code]

AppDelegate.h

[code]
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder

@property (strong, nonatomic) UIWindow *window;

@end[/code]

AppDelegate.m

#import "AppDelegate.h"
#import "BNRHypnosisView.h"

@interface AppDelegate ()

@end

@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    CGRect topFrame = [[UIScreen mainScreen] bounds];
    self.window = [[UIWindow alloc] initWithFrame: topFrame];
    
    // Add a centered view
    /*const CGFloat W = topFrame.size.width;
    const CGFloat H = topFrame.size.height;*/
    CGRect firstFrame = [[self window] bounds];
    UIView * firstView = [[UIView alloc] initWithFrame:firstFrame];    // Replace this with your custom view
    firstView.backgroundColor = [UIColor redColor];
    
    UIViewController * viewController = [[UIViewController alloc] init];
    
    // Replace the default view...
    [viewController.view addSubview:firstView];
    
    
    // Make this the root view controller...
    self.window.rootViewController = viewController;
    
    [self.window setBackgroundColor:[UIColor whiteColor]];
    [self.window makeKeyAndVisible];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

I’m using Xcode 7 btw

#2

That’s probably because you are not using the BNRHypnosisView:

[quote][code]

UIView * firstView = [[UIView alloc] initWithFrame:firstFrame]; // Replace this with your custom view
firstView.backgroundColor = [UIColor redColor];

UIViewController * viewController = [[UIViewController alloc] init];

// Replace the default view...
[viewController.view addSubview:firstView];
...

[/code][/quote]

#3

OOps my bad…