我正在开发基于集合视图的项目,根据用户点击特定索引,将更改Numberofitem并增加其数量.所有在我的项目中完美运行,但我无法根据集合视图中的单元格数设置单元格大小.更多集合视图将无法滚动所有单元格修复视图中的调整大小.在这里,我附上了所有图像.
1)故事板视图
2)四个细胞的结果
3)当细胞数量增加时
目前我通过以下代码以这种方式完成了我的单元格设置.但我想设置一下,如果集合视图中有四个单元格,那么每个单元格的大小会根据集合视图和设备大小增加和拟合(iphone 5s,iphone 6,iphone 6plus)
这是我的尝试,
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
return 5.0;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
return 5.0;
}
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
////@property NSInteger count;////
if (_count == 0) {
// width = ((width - (span*5))/4);
// return CGSizeMake(self.view.frame.size.width/4, self.view.frame.size.height/4);
return CGSizeMake(self.view.frame.size.width/2.5, self.view.frame.size.height/5);
}
if (_count == 1 || _count == 2)
{
return CGSizeMake(self.view.frame.size.width/2.5, self.view.frame.size.height/5);
// return CGSizeMake(100.0, 100.0);
}
if ( _count == 3 || _count == …
Run Code Online (Sandbox Code Playgroud) 我想要iPhone的唯一设备ID保持不变?,我想要卸载应用程序并在同一设备上再次安装时无法更改的唯一设备ID.我正在使用swift 2.1.1和xcode 7.2.1.我已经尝试过这段代码,但两者都无效.
//第一种方法
让device_id = UIDevice.currentDevice().identifierForVendor!.UUIDString
print("unique device id:(device_id)")
//第二种方法
让dID = CFUUIDCreate(kCFAllocatorDefault)
让deviceID = CFUUIDCreateString(kCFAllocatorDefault,dID)为NSString
print("唯一的CFUUID id:(deviceID)")
我正在编写一个使用Core Audio新的iOS 7 Inter App Audio技术的HOST应用程序.我已经设法在Inter-App音频示例的帮助下获得乐器应用和效果应用 .
问题是,效果节点是依赖于仪器节点.我想使节点和仪器节点独立.
在这里,我的尝试.
if (desc.componentType == kAudioUnitType_RemoteEffect) {
// if ([self isRemoteInstrumentConnected]) {
if (!_engineStarted) // Check if session is active
[self checkStartOrStopEngine];
if ([self isGraphStarted]) // Check if graph is running and or is created, if so, stop it
[self checkStartStopGraph];
if ([self checkGraphInitialized ]) // Check if graph has been inititialized if so, uninitialize it.
Check(AUGraphUninitialize(hostGraph));
Check (AUGraphAddNode (hostGraph, &desc, &effectNode)); …
Run Code Online (Sandbox Code Playgroud) 我正在开发基于XMPP的ios项目.我想发送消息,但我无法发送消息.表示接收方不会收到该消息.这是我的代码.
- (IBAction)sendMessageNow:(id)sender
{
NSString *messageStr =messageField.text;
if([messageStr length] > 0)
{
NSLog(@"Message sending fron Gmail");
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:messageStr];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:@"destination address"];
[message addChild:body];
NSLog(@"message1%@",message);
[[self appDelegate].xmppStream sendElement:message];
}
NSDate *date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"hh:mm a"];
//[self sendMessage];
if ([self.messageField.text length]>0) {
if (isfromMe)
{
NSString *rowNum=[NSString stringWithFormat:@"%d",(int)sphBubbledata.count];
[self adddMediaBubbledata:kTextByme mediaPath:self.messageField.text mtime:[formatter stringFromDate:date] thumb:@"" downloadstatus:@"" sendingStatus:kSending msg_ID:[self genRandStringLength:7]];
[self performSelector:@selector(messageSent:) …
Run Code Online (Sandbox Code Playgroud) 我正在为iphone 6和6Plus定制键盘.我已经为shift键激活 - 非激活或123和abc键开发逻辑.但我想显示自定义符号,如显示的苹果键盘.请检查图像.
目前我能够将大写改为小写,将123改为abc但是如何设置这个特殊字符.注意: - 我在github上搜索了很多演示,但我无法在任何自定义键盘中看到特殊字符.
这是我的大写和ABC-123按钮的逻辑.
-(void)UpparCase:(UIButton*)sender // To make caps or small letter
{
sender.selected=!sender.selected;
if(sender.selected)
{
if(isPortrait)
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"upparActive.png"] forState:UIControlStateNormal];
}
else
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_selctd_land.png"] forState:UIControlStateNormal];
}
for(UIButton *key in self.ObjKeyLayout.ArryCharKey)
{
NSString *uppercaseString = [[key currentTitle] uppercaseString];
[key setTitle:uppercaseString forState:UIControlStateNormal];
[key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside];
}
}
else
{
if(isPortrait)
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"UpperCase.png"] forState:UIControlStateNormal];
}
else
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_land.png"] forState:UIControlStateNormal];
}
for(UIButton *key in self.ObjKeyLayout.ArryCharKey)
{
NSString …
Run Code Online (Sandbox Code Playgroud) 我打算制作网格基础应用程序,其中网格数量将根据用户的点击而改变.网格模式: - 2*2,4*4 ... [比如,用户将点击正确的网格,然后网格数量将增加].我能够制作网格,但它不适合布局.那么,如何更改用户点击的网格数量以及如何动态设置网格的大小.
在这里,我附上了我想要实现的图像.
当用户点击上不同颜色的格子,格子的数量将增加像第二图像.
图片:1
图片:2
用户点击时网格数量增加.
我想在iPhone 5s中测试我的应用程序.它有最新的ios版本.所以,我删除了旧的Xcode V 7.0.1并安装了新的版本v 7.2.
安装v 7.2后,我收到以下错误.
CodeSign错误:SDK'iOS 9.2'中的产品类型'Unit Test Bundle'需要代码签名
我已经检查了这个问题代码签名是必需的产品类型单元测试捆绑在-sdk-ios-8-0并尝试所有的答案,但我仍然遇到这个问题.
我有一般的设置构建目标以及信息选项卡.即使我没有得到代码登录错误来解决问题.但仍无法在我的测试设备中运行应用程序.
代码签名也正确设置.
还从我的应用程序中删除了Test Project.
我想在我的Mac上编译一个简单的helloworld.c,然后将其发送到我的iphone 4上运行.
代码很简单:
#include <stdio.h>
int main( ) {
printf("Hello, world!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的设置:
OSX El Capitain 10.11
Xcode 7.2
Iphone4搭配iOS 7.1.4 JB
clang -v Apple LLVM版本7.0.2(clang-700.1.81)目标:x86_64-apple-darwin15.3.0线程模型:posix
gcc -v配置: - prefix =/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir =/usr/include/c ++/4.2.1 Apple LLVM 7.0.2版(clang -700.1.81)目标:x86_64-apple-darwin15.3.0线程模型:posix
iPhoneOS9.0.2.sdk
我在网上找到的所有信息都没有用,因为新的Xcode或最近OSX上的新编译器.
我正在研究GPUImage库.我已经设置了特定的过滤器将应用于Collectionview的didselectitematindexpath
方法.这是我的第一个基于GPUImage库的项目.我成功地能够在GPUImageview上应用Filter,但是应用过滤器会花费大量时间.请指导我,如何快速申请.
这是我的代码,
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[filter removeAllTargets];
if (indexPath.row==0) {
NSLog(@"Normal Filter");
}
else if (indexPath.row==1)
{
filter = [[GPUImageSepiaFilter alloc] init];
}
else if (indexPath.row==2)
{
filter = [[GPUImagePixellateFilter alloc] init];
}
else if (indexPath.row==3)
{
filter = [[GPUImagePixellatePositionFilter alloc] init];
}
else if (indexPath.row==4)
{
filter = [[GPUImagePolkaDotFilter alloc] init];
}
else if (indexPath.row==5)
{
filter = [[GPUImageHalftoneFilter alloc] init];
}
else if (indexPath.row==6)
{
filter = [[GPUImageCrosshatchFilter alloc] init];
}
else …
Run Code Online (Sandbox Code Playgroud) 我收到的错误就像
:未知类型名称'AppDelegate'
:未知类型名称'AppDelegate'
:具有"弱"属性的属性必须是对象类型
我已经提到了很多像这样的问题,但都给出了像添加的答案
@class Appdelegate;
Run Code Online (Sandbox Code Playgroud)
我尝试编辑此代码,但在此之后它给出了错误
:AppDelegate.m:23:18:'ddLogLevel'的重新定义
因为此日志是在两个视图控制器中定义的.我也尝试从上面的视图控制器评论此日志的行,但它会给出错误
:/ChatViewController.m:440:13:使用未声明的标识符'ddLogLevel'
现在有什么解决方案?
编辑:我必须这样声明.因为我正在研究xmpp.所以我必须[[self appDelegate] connect]
在另一个视图控制器中调用方法.
- (AppDelegate *)appDelegate
{
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
Run Code Online (Sandbox Code Playgroud)
编辑
//Appdelegate.h file //
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "ViewController.h"
#import "MBProgressHUD.h"
#import "FriendsViewController.h"
#import <CoreData/CoreData.h>
#import "XMPPFramework.h"
//@class FriendsViewController;
@class ViewController;
@interface AppDelegate : NSObject <UIApplicationDelegate, XMPPRosterDelegate>
{
XMPPStream *xmppStream;
XMPPReconnect *xmppReconnect;
XMPPRoster *xmppRoster;
XMPPRosterCoreDataStorage *xmppRosterStorage;
XMPPvCardCoreDataStorage *xmppvCardStorage;
XMPPvCardTempModule *xmppvCardTempModule;
XMPPvCardAvatarModule *xmppvCardAvatarModule;
XMPPCapabilities *xmppCapabilities;
XMPPCapabilitiesCoreDataStorage *xmppCapabilitiesStorage;
NSString *password;
BOOL customCertEvaluation;
BOOL …
Run Code Online (Sandbox Code Playgroud) 这是我的示例输出,在下面的详细信息中有三个单元格,我为每个自定义单元格设置了角半径。但它无法正常工作。第一个单元格的角半径不起作用,对于第二个单元格,右上角和顶部左边正在工作,请说一下该怎么做
-(void)layoutSubviews
{
[super layoutSubviews];
self.backgroundColor = [UIColor clearColor];
self.contentView.layer.cornerRadius =5;
self.contentView.layer.masksToBounds = YES;
}
Run Code Online (Sandbox Code Playgroud)
我已将上述代码应用于我的单元格类文件
我正在研究基于GPUImageView的应用程序.我已正确实现所有功能,但我无法使用GPUImageview捕获屏幕截图.
在这里,我还在我的Github上附加了演示.
注意:我试图用renderInContext截取屏幕截图:但它对我没用.
ios ×10
objective-c ×6
gpuimage ×2
xcode ×2
android ×1
c ×1
code-signing ×1
core-audio ×1
grid ×1
gridview ×1
ios7 ×1
iphone ×1
llvm ×1
macos ×1
uitableview ×1
xcode6 ×1