Laz*_*olj 7 git delegates datasource objective-c ios
所以我将Xcode和GitHub项目代码升级到swift 3.0(我的项目在Obj C中,我在GitHub中使用的一些pod都在Swift中).我收到了一些错误,现在我被困在这些错误上了.出于某种原因,我的floatingSctionButton(git here)的dataSource和delegate 现在不起作用.我尝试设置dataSource和delegate编程和故事板,但它没有工作.
错误:
在'LiquidFloatingActionButton*'类型的对象上找不到属性'dataSource'
在'LiquidFloatingActionButton*'类型的对象上找不到属性'委托'
我相信,如果我弄清楚dataSource并delegate发出问题,那么它将修复下面的颜色错误.
.H:
#import <UIKit/UIKit.h>
#import "ProductContentViewController.h"
#import "LiquidFloatingActionButton-swift.h"
@interface SetScreenViewController : UIViewController
<UIPageViewControllerDataSource, LiquidFloatingActionButtonDelegate, LiquidFloatingActionButtonDataSource>
...
@end
Run Code Online (Sandbox Code Playgroud)
.M:
#import "LiquidFloatingActionButton-Swift.h"
LiquidFloatingActionButton *floatingActionButton;
NSMutableArray *liquidCells;
bool *closeFloatingButtons;
NSString *videoToWatchURL;
- (void)addLiquidButton{
//Grabs the coordinates bottom right of the screen
float X_Co = self.view.frame.size.width - 50;
float Y_Co = self.view.frame.size.height - 50;
//i subtract 10 so the button will be placed a little bit out
X_Co = X_Co - 10;
Y_Co = Y_Co - 10;
//I create each cell and set the image for each button
liquidCells = [[NSMutableArray alloc] init];
[liquidCells addObject:[[LiquidFloatingCell alloc]initWithIcon:[UIImage imageNamed:@".png"]]];
[liquidCells addObject:[[LiquidFloatingCell alloc]initWithIcon:[UIImage imageNamed:@".png"]]];
[liquidCells addObject:[[LiquidFloatingCell alloc]initWithIcon:[UIImage imageNamed:@".png"]]];
[liquidCells addObject:[[LiquidFloatingCell alloc]initWithIcon:[UIImage imageNamed:@".png"]]];
[liquidCells addObject:[[LiquidFloatingCell alloc]initWithIcon:[UIImage imageNamed:@".png"]]];
[liquidCells addObject:[[LiquidFloatingCell alloc]initWithIcon:[UIImage imageNamed:@".png"]]];
//Sets the floating button at the loaction provided
floatingActionButton = [[LiquidFloatingActionButton alloc] initWithFrame:CGRectMake(X_Co, Y_Co, 50, 50)];
floatingActionButton.dataSource = self;//Error here
floatingActionButton.delegate = self;//and here.
//I set the color of the floating button
floatingActionButton.color = [self colorWithHexString:@"01b8eb"];
//Enables the user interaction fuction to true so itll open or close
floatingActionButton.userInteractionEnabled = YES;
//Adds the flaoting button to the view
[self.view addSubview:floatingActionButton];
}
-(NSInteger)numberOfCells:(LiquidFloatingActionButton *)liquidFloatingActionButton{
return liquidCells.count;
}
-(LiquidFloatingCell *)cellForIndex:(NSInteger)index{
return [liquidCells objectAtIndex:index];
}
Run Code Online (Sandbox Code Playgroud)
PodFile:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'Whats New' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for Whats New
target 'Whats NewTests' do
inherit! :search_paths
# Pods for testing
end
target 'Whats NewUITests' do
inherit! :search_paths
# Pods for testing
end
pod 'CRToast', '~> 0.0.7'
pod "LiquidFloatingActionButton"
pod 'DGActivityIndicatorView'
pod 'M13ProgressSuite'
pod 'SDWebImage', '~>3.8'
pod 'FSCalendar'
use_frameworks!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
更新下面
我最终使用这个项目是因为原来的GitHub没有得到修复,感谢所有的帮助,如果有人想出来,请让大家知道!
我认为问题是你的 Objective-C 代码不知道 \xe2\x80\x9e open var\xe2\x80\x9csdataSource和Swiftdelegate代码LiquidFloatingButton。
\n为了让它们为人所知,需要一个 Obj-c 头文件来将这些 Swift 信息公开给您的 Obj-C 代码。Apple 文档 \xe2\x80\x9e Swift and Objective-C in the Same Project \xe2\x80\x9c对此进行了详细描述,在您的情况下,特别是在 \xe2\x80\x9e导入外部框架\xe2\部分x80\x9c。它说:
\n您可以使用以下语法将框架导入到不同目标中的任何 Objective-C .m 文件中:
@import FrameworkName;\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
897 次 |
| 最近记录: |