Kjuly / KYCircleMenu

An iOS UI control that allows you to build a circular menu by laying out buttons in a circle pattern adjusting from the number of buttons (1~6).
MIT License
786 stars 154 forks source link

Push a ViewController.... How to? #1

Closed AndrexOfficial closed 11 years ago

AndrexOfficial commented 11 years ago

Hi, how can I push a ViewController with a nib file and set its tag?

can you write down the code?

Thanks

Kjuly commented 11 years ago

Sorry for my late reply. Just init your view controller, and KYCircleMenu has a instance method: -pushViewController:, it'll manage the action of pushing view controller very well.

- (void)runButtonActions:(id)sender {
  [super runButtonActions:sender];
  // init your view controller with `-initWithNib:...` method
  ...
  // push your view controller by `-pushViewController:`
  [self.yourCircleMenu pushViewController:yourViewController];
  ...
}
AndrexOfficial commented 11 years ago

Okay, but i can't assign a specific tag to that action How can i fix it?

Kjuly commented 11 years ago

@AndrexOfficial assign tag to your buttons, not view controller, if you need to modify the tag for the buttons, you can get the button by tag, then reassign the tag for it. :)

Let say you want to modify the 3rd button's tag:

UIButton * targetButton = (UIButton *)[self.yourCircleMenu viewWithTag:3];
[targetButton setTag:yourSpecificTag];
AndrexOfficial commented 11 years ago

Okay, not I'm having another issue, I have a xib file called MainView and belongs to AppDelegate inside there is a tabbar controller with an array of views (nv1,nv2,nv3) but when i implement the KYCircle Menu and I launch the simulator I get a tabbar working but with a white view and no navigation bar (the navigation bar appears and then disappear very quickly) How can i manage this with your menu?

Kjuly commented 11 years ago

// The default case is that the navigation bar is only shown in child views. // If it is needed to be shown with the circle menu together, // just copy this macro into your own config file & comment it out. // // #define KY_CIRCLEMENU_WITH_NAVIGATIONBAR 1

So, put #define KY_CIRCLEMENU_WITH_NAVIGATIONBAR 1 at top of your class or anther other files that are compiled before your root view controller. If you are just using this lib, de-commentout this line is fine.

B.t.w, it is included in KYCircleMenu.h.

Hope this'll helps. :)

Kjuly commented 11 years ago

And when you want to set the tab view controller as your root vc, you need to set the child view controllers for it. If the KYCircleMenu instance is one of your tab, don't forget to set it. I think that's why you got a white view.

AndrexOfficial commented 11 years ago

No, it doesn't work: here is my code

import "AppDelegate.h"

import "ADVTheme.h"

import <UIKit/UIKit.h>

import <AVFoundation/AVFoundation.h>

import <AudioToolbox/AudioToolbox.h>

import "GAI.h"

import "KKPasscodeLock.h"

import "KnobViewController.h"

import "RadioViewController.h"

import "Constants.h"

define KY_CIRCLEMENU_WITH_NAVIGATIONBAR 1

/*** Set your tracking ID here ***/ static NSString *const kTrackingId = @"UA-TRACKING-ID";

@implementation AppDelegate

@synthesize window; @synthesize rootController; @synthesize nv1, nv2, nv3, nv4, nv5;

pragma mark -

pragma mark Application lifecycle

// method for startup splash screen animation

}

pragma mark -

pragma mark Memory management

@end

Kjuly commented 11 years ago

I found that you tried to set a navigation controller (not a tab vc) as the root vc... Just take a try to remove

NSArray* controllers = [NSArray arrayWithObjects:nv1, nv2, nv3, nv4, nil];
rootController.viewControllers = controllers;

part in the code snippet below:

// Set navigation controller as the root vc
[self.window setRootViewController:navigationController];
[navigationController release];
NSArray* controllers = [NSArray arrayWithObjects:nv1, nv2, nv3, nv4, nil];
rootController.viewControllers = controllers;
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];

And b.t.w, have you setup values for kKYCCircleMenuButtonsCount, ...? As these are my demo constants.

ssaaaranraj commented 8 years ago

how can i add images in the circle...

ssaaaranraj commented 8 years ago

how can i add images in circle ( Kycircle menu)

Kjuly commented 8 years ago

@ssaaaranraj there's

#define kKYICircleMenuButtonImageNameFormat  @"KYICircleMenuButton%.2d.png" // %.2d: 1 - 6

in demo project. And in this case, just provide KYICircleMenuButton01(@2x).png ... KYICircleMenuButton06(@2x).png.

u can provide ur own image name format (buttonImageNameFormat) in init method

- (instancetype)initWithButtonCount:(NSInteger)buttonCount
                           menuSize:(CGFloat)menuSize
                         buttonSize:(CGFloat)buttonSize
              buttonImageNameFormat:(NSString *)buttonImageNameFormat
                   centerButtonSize:(CGFloat)centerButtonSize
              centerButtonImageName:(NSString *)centerButtonImageName
    centerButtonBackgroundImageName:(NSString *)centerButtonBackgroundImageName;

Btw, plz open new issue next time, thx :)