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

Add CircleMenuViewController into a ViewController #7

Closed tuandao closed 11 years ago

tuandao commented 11 years ago

Hi,

As your demo you add CircleMenuViewController into AppDelegate. But in my case, I need to add CircleMenuViewController into my ViewController

Here us my code

@implementation SubmitListViewController

- (void)viewDidLoad
{
    //SubmitAdsViewController.delegate = self;
    // Circle Menu
    CircleMenuViewController * circleMenuViewController=
    [[CircleMenuViewController alloc]initWithButtonCount:kKYCCircleMenuButtonsCount
                                                menuSize:kKYCircleMenuSize
                                              buttonSize:kKYCircleMenuButtonSize
                                   buttonImageNameFormat:kKYICircleMenuButtonImageNameFormat
                                        centerButtonSize:kKYCircleMenuCenterButtonSize
                                   centerButtonImageName:kKYICircleMenuCenterButton
                         centerButtonBackgroundImageName:kKYICircleMenuCenterButtonBackground];
    [self.view addSubview:circleMenuViewController.view];
}

When I compile I got this error: Undefined symbols for architecture i386: "_OBJCCLASS$_CircleMenuViewController", referenced from: objc-class-ref in SubmitListViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried to use KYCircleMenu.h directly instead of CircleMenuViewController , that works, but when I tap on the center button it crash as well.

Do you have any introduction for my case. Thanks in advance.

Kjuly commented 11 years ago

Hi @tuandao , I'm on my way to Tibet, I'll try to help you to solve the issue when it is available! (Maybe several days later..) Hope you can understand! Thank you! :)

tuandao commented 11 years ago

Thanks Kjuly, I can wait ;)

Kjuly commented 11 years ago

I tried but didn't get this error..

How did you add reference to the KYCircleMenu lib? I suggest you to add refer to _KYCircleMenu/KYCircleMenu_ only (i.e., only _KYCircleMenu.h/m_ are needed), do not add refer to _KYCircleMenuDemo_.

fabiomassimo commented 11 years ago

I have got the same problem with storyboard.. how can i instantiate KYCircleMenu inside a UIViewController that I use in storyboard? So I can link the menu's button with a performSegue method...

Kjuly commented 11 years ago

Sorry @fabiomassimo , I do not use storyboard... :(

SixFiveSoftware commented 11 years ago

@fabiomassimo I did it by just target-action method. From a UIButton on your main view controller (or some control that has a target action), in the method the button calls upon the TouchUpInside event, have that method instantiate the subclass of KYCircleMenu. Then in your subclass's method you override for obtaining which button in the circle menu the user tapped, then you perform segue.

tuandao commented 11 years ago

Hi Kjuly, I just added the core lib files, not ref to the demo folder. But I am using storyboard, I think that is the problem. Hmmm, I will retry.

fabiomassimo commented 11 years ago

@SixFiveSoftware Will you post a Storyboard example with KYCircleMenu?. I think it would be very helpful. Thanks.

SixFiveSoftware commented 11 years ago

Sure thing. I'm putting my project folder in my dropbox, linked here: https://dl.dropbox.com/u/17455146/SFSCircleMenuDemo.zip. Since KYCircleMenu is not ARC-compliant, I had to make some modifications to it, just removed the dealloc method, and removed any calling of a release method.

As for @tuandao, your error indicates that you are not including the .m file in your Compile Sources in your Build Phases tab. See this Stack Overflow article: http://stackoverflow.com/questions/6984368/undefined-symbols-for-architecture-i386-objc-class-skpsmtpmessage-refere.

To get this working with Storyboards, I had to implement a quick delegate pattern in my subclass (arguably, KYCircleMenu could be altered to use the delegate pattern rather than subclassing to be a little more storyboard-friendly and direct you in what methods need to be provided by you with the @required methods). All the delegate method does is call performSegue:withIdentifier:. I'm not the best at Git otherwise I would offer to help the project, but @Kjuly is probably smart enough to do it. (@Kjuly, if you are open to me helping, I'd love to, let me know and I can email you at the email in your profile).

fabiomassimo commented 11 years ago

@SixFiveSoftware great work! Thank you! You definitely help me out... now the last thing that would be helpful to this library is autorotate support but my suggestion is to commited storyboard's support. Thanks again and of course thanks to @Kjuly for this library.

Kjuly commented 11 years ago

@SixFiveSoftware Good job! Feel free to improve the lib! You can just contact me via the mail. :) And for ARC problem, you can add -fno-objc-arc for the KYCircleMenu lib in your ARC project. HERE's a good post about it.

@tuandao @fabiomassimo , does @SixFiveSoftware 's patch works well?

nmzahid commented 11 years ago

hi! i used the same code as @tuandao and i see the main centre button on my screen but when i tap on it i get exc_bad_access code=2 exception. I don't know what's wrong. I'm not using storyboards . I want to show this as a subview on my screen and not as a separate view

I am using this code to create a subview

CircleMenuViewController * circleMenuViewController;
  circleMenuViewController = [CircleMenuViewController alloc];
  (void)[circleMenuViewController initWithButtonCount:kKYCCircleMenuButtonsCount
                                             menuSize:kKYCircleMenuSize
                                           buttonSize:kKYCircleMenuButtonSize
                                buttonImageNameFormat:kKYICircleMenuButtonImageNameFormat
                                     centerButtonSize:kKYCircleMenuCenterButtonSize
                                centerButtonImageName:kKYICircleMenuCenterButton
                      centerButtonBackgroundImageName:kKYICircleMenuCenterButtonBackground];

[self.view addSubview:circleMenuViewController.view];
Kjuly commented 11 years ago

How about setting circleMenuViewController as an iVar?

@property (nonatomic, retain)  CircleMenuViewController * circleMenuViewController;

then modify your code snippet appropriately.

nmzahid commented 11 years ago

it works now! thanks a lot!

Kjuly commented 11 years ago

@nmzahid pleasure :)