我只是Swift语言的新生开发者。 我想将textfield委托分配给视图控制器。我试着像这样分配
Calendar calendar2,calendar,cal,cal2;
calendar = new GregorianCalendar();
calendar2 = new GregorianCalendar();
calendar2.setTimeInMillis(System.currentTimeMillis());
calendar.setTimeInMillis(System.currentTimeMillis());
cal = new GregorianCalendar();
cal2 = new GregorianCalendar();
cal.add(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR));
cal.set(Calendar.HOUR_OF_DAY, 10);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, calendar.get(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, calendar.get(Calendar.MILLISECOND));
cal.set(Calendar.DATE, calendar.get(Calendar.DATE));
cal.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Intent it = new Intent(MainActivity.this,Start_service_alarm.class);
it.putExtra(Start_service_alarm.ACTION, Start_service_alarm.ACTION);
PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 987654321, it, 0);
if(android.os.Build.VERSION.SDK_INT<19)
{
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
}else
{
alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
}
cal2.add(Calendar.DAY_OF_YEAR, calendar2.get(Calendar.DAY_OF_YEAR));
cal2.set(Calendar.HOUR_OF_DAY, 20);
cal2.set(Calendar.MINUTE, 0);
cal2.set(Calendar.SECOND, calendar2.get(Calendar.SECOND));
cal2.set(Calendar.MILLISECOND, calendar2.get(Calendar.MILLISECOND));
cal2.set(Calendar.DATE, calendar2.get(Calendar.DATE));
cal2.set(Calendar.MONTH, calendar2.get(Calendar.MONTH));
AlarmManager alarmManager2 = (AlarmManager)getSystemService(ALARM_SERVICE);
Intent itIntent = new Intent(MainActivity.this,Stop_service_alarm.class);
itIntent.putExtra("ACTION_STOP", Stop_service_alarm.ACTION_STOP);
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(MainActivity.this, 123456789, itIntent, 0);
if(android.os.Build.VERSION.SDK_INT<19)
{
alarmManager2.setRepeating(AlarmManager.RTC_WAKEUP, cal2.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent2);
}else
{
alarmManager2.setExact(AlarmManager.RTC_WAKEUP, cal2.getTimeInMillis(), pendingIntent2);
}
返回以下错误“无法专门化非泛型类型'UIViewController'”
答案 0 :(得分:4)
您需要使用逗号添加要符合的协议:
class LoginViewController: UIViewController, UITextFieldDelegate
您只能从一个类扩展 ,但要符合您想要的任意数量的协议:
class LoginViewController: UIViewController, UITextFieldDelegate, UIAlertViewDelegate
来自Apple doc:
class SomeClass: SomeSuperclass, FirstProtocol, AnotherProtocol {
// class definition goes here
}
答案 1 :(得分:0)
请使用逗号添加代理/数据源/协议:
class MyClass: UIViewController ,UITableViewDelegate, UITableViewDataSource ..
{...}
答案 2 :(得分:0)
我想补充一点,您可以通过符合班级 USE tempdb;
IF OBJECT_ID('tempdb..#BOM') IS NOT NULL
DROP TABLE #BOM;
CREATE TABLE #BOM
(
ITEMID NVARCHAR(10) ,
BOMID NVARCHAR(10) ,
MATERIALNAME NVARCHAR(10)
);
INSERT INTO #BOM
VALUES ( N'113621', -- ITEMID - nvarchar(10)
N'1', -- BOMID - nvarchar(10)
N'Wood' -- MATERIALNAME - nvarchar(10)
);
INSERT INTO #BOM
VALUES ( N'234517', -- ITEMID - nvarchar(10)
N'2', -- BOMID - nvarchar(10)
N'Metal' -- MATERIALNAME - nvarchar(10)
);
INSERT INTO #BOM
VALUES ( N'378654', -- ITEMID - nvarchar(10)
N'3', -- BOMID - nvarchar(10)
N'Glass' -- MATERIALNAME - nvarchar(10)
);
IF OBJECT_ID('tempdb..#BOMVERSION') IS NOT NULL
DROP TABLE #BOMVERSION;
CREATE TABLE #BOMVERSION
(
ITEMID NVARCHAR(10) ,
BOMID NVARCHAR(10) ,
NAME NVARCHAR(20)
);
INSERT INTO #BOMVERSION
VALUES ( N'113477', -- ITEMID - nvarchar(10)
N'1', -- BOMID - nvarchar(10)
N'Oak' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113608', -- ITEMID - nvarchar(10)
N'1', -- BOMID - nvarchar(10)
N'Pine' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113622', -- ITEMID - nvarchar(10)
N'1', -- BOMID - nvarchar(10)
N'Wood Table' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113683', -- ITEMID - nvarchar(10)
N'2', -- BOMID - nvarchar(10)
N'Aluminium' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113689', -- ITEMID - nvarchar(10)
N'2', -- BOMID - nvarchar(10)
N'Steel' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113693', -- ITEMID - nvarchar(10)
N'2', -- BOMID - nvarchar(10)
N'Metal table' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113694', -- ITEMID - nvarchar(10)
N'3', -- BOMID - nvarchar(10)
N'Glass' -- NAME - nvarchar(10)
);
INSERT INTO #BOMVERSION
VALUES ( N'113695', -- ITEMID - nvarchar(10)
N'3', -- BOMID - nvarchar(10)
N'Glass BookCase' -- NAME - nvarchar(10)
);
--Query
WITH BOM1
AS ( SELECT B.ITEMID AS BITEMID ,
BV.ITEMID AS BVITEMID ,
B.MATERIALNAME ,
B.BOMID
FROM #BOM AS B
JOIN #BOMVERSION AS BV ON BV.BOMID = B.BOMID
),
EXPLODE
AS ( SELECT B.BITEMID ,
B.MATERIALNAME ,
B.BVITEMID ,
B.BOMID ,
0 AS [Level]
FROM BOM1 AS B
UNION ALL
SELECT B.BITEMID ,
E.MATERIALNAME ,
E.BVITEMID ,
E.BOMID ,
[E].[Level] + 1
FROM EXPLODE AS E
JOIN BOM1 AS B ON B.BOMID = E.BOMID
WHERE E.Level <= 6 --narrowing levels
)
SELECT *
FROM EXPLODE PIVOT ( MAX(BVITEMID) FOR Level IN ( [0], [1], [2], [3],
[4], [5], [6], [7] ) ) AS PVTBOM;
中的协议来分离代码,以提高可读性:
extension
我个人更喜欢这种方法。